A filter for Kubernetes manifests that resolves Keeper URIs in Secret resources using ksm
Project description
Keepomize
A filter for Kubernetes manifests that resolves Keeper URIs in Secret resources using the ksm command-line tool.
Overview
Keepomize is designed to work in a pipeline after Kustomize to resolve Keeper URIs in Kubernetes Secret manifests. It reads a multi-document YAML stream from stdin, finds any Kubernetes Secret resources, and replaces Keeper URIs (keeper://RECORDID/fieldspec) in their stringData and data fields by resolving them through ksm.
Prerequisites
- Python 3.8 or higher
- The
ksmcommand-line tool must be installed and available in your PATH - Access to Keeper secrets that you want to resolve
- Any
KSM_*environment variables needed forksmconfiguration (automatically passed through)
Installation
From PyPI
pip install keepomize
From source
git clone https://github.com/nathanic/keepomize.git
cd keepomize
uv sync
uv run keepomize --help
Development installation
git clone https://github.com/nathanic/keepomize.git
cd keepomize
uv sync --dev
Usage
Basic usage
# Use with kustomize and kubectl
kustomize build overlays/production | keepomize | kubectl apply -f -
# Use with kustomize and oc (OpenShift)
kustomize build overlays/production | keepomize | oc apply -f -
Example Secret manifest
Before processing:
apiVersion: v1
kind: Secret
metadata:
name: my-app-secrets
namespace: default
type: Opaque
stringData:
database-password: keeper://MySQL Database/field/password
api-key: keeper://API Keys/field/api_key
username: keeper://MySQL Database/field/login
data:
secret-token: keeper://Auth Service/field/token # Will be base64 encoded
After processing with keepomize:
apiVersion: v1
kind: Secret
metadata:
name: my-app-secrets
namespace: default
type: Opaque
stringData:
database-password: my-actual-password
api-key: sk-1234567890abcdef
username: mysql_user
data:
secret-token: bXktYWN0dWFsLXRva2Vu # base64 encoded value
Keeper URI format
Keeper URIs use Keeper notation which follows this format:
keeper://<TITLE|UID>/<selector>/<parameters>[[predicate1][predicate2]]
Common examples for Kubernetes Secrets:
keeper://MySQL Creds/field/password
keeper://API Keys/field/api_key
keeper://Contact/field/name[first]
keeper://Record/custom_field/phone[1][number]
Where:
- First segment: Record title or unique identifier (UID)
- Selector:
fieldfor standard fields,custom_fieldfor custom fields,filefor files - Parameters: Field name or other identifiers
- Predicates (optional): Array indices
[0]and sub-field access[property]
Note: Special characters (/, \, [, ]) in record details must be escaped with backslash.
How it works
- Input: Reads multi-document YAML from stdin
- Processing:
- Identifies Kubernetes Secret resources (where
kind: Secret) - Scans
stringDataanddatafields for Keeper URIs - Resolves URIs using
ksm secret notationcommand - For
datafields, base64 encodes the resolved values
- Identifies Kubernetes Secret resources (where
- Output: Writes the modified YAML to stdout
Integration with CI/CD
# GitHub Actions example
- name: Deploy with secret resolution
run: |
kustomize build overlays/production | keepomize | kubectl apply -f -
env:
KSM_CONFIG: ${{ secrets.KSM_CONFIG }}
KSM_TOKEN: ${{ secrets.KSM_TOKEN }}
# Any KSM_* environment variables are automatically passed to ksm
Error handling
Keepomize will:
- Exit with status code 1 if
ksmis not found in PATH - Exit with status code 1 if any Keeper URI fails to resolve
- Print error messages to stderr while preserving stdout for the YAML output
- Preserve all non-Secret resources unchanged
Development
Running tests
uv run pytest
Building for distribution
uv build
Publishing to PyPI
uv publish
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Changelog
0.1.2
- Critical Bug Fixes:
- Fixed trailing newline handling - ksm output now has trailing newlines stripped to prevent malformed secret values
- Fixed environment variable inheritance - ksm subprocess now inherits full environment (preserves HOME, SSL_CERT_FILE, proxy settings, etc.)
- Testing: Added comprehensive tests for newline handling edge cases and environment inheritance
0.1.1
- Bug Fix: Fixed CLI argument parsing to restore --help functionality
- Testing: Added sys.argv patches to CLI tests for proper argument handling
0.1.0
- Initial release
- Support for resolving Keeper URIs in Secret stringData and data fields
- CLI tool with proper error handling
- Full test suite
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keepomize-0.1.2.tar.gz.
File metadata
- Download URL: keepomize-0.1.2.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
794bf9e62d90ba46afa1d16d03954aacc5c29c97b4f989155692ceb6a03dbbd9
|
|
| MD5 |
7f98a33b4ee038e7f469d1530b6c49c2
|
|
| BLAKE2b-256 |
e77a298985d8d54106102b977bd30cb5dd7cb0bd9db52a85a519aba940231515
|
Provenance
The following attestation bundles were made for keepomize-0.1.2.tar.gz:
Publisher:
release.yml on nathanic/keepomize
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keepomize-0.1.2.tar.gz -
Subject digest:
794bf9e62d90ba46afa1d16d03954aacc5c29c97b4f989155692ceb6a03dbbd9 - Sigstore transparency entry: 393326798
- Sigstore integration time:
-
Permalink:
nathanic/keepomize@23e562a6095c8c78cf8b39195d1d26e651426389 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/nathanic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@23e562a6095c8c78cf8b39195d1d26e651426389 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file keepomize-0.1.2-py3-none-any.whl.
File metadata
- Download URL: keepomize-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30ab270c813e09a56391e563d5ac4ee1755d56dda4486706834bcbcc0362649f
|
|
| MD5 |
0ee76d2cd76accc0cd416d884755b0f9
|
|
| BLAKE2b-256 |
a1230b2739d3a8e4f52752df5624acc8d55cdd643e6a7bd50d1c0710318e67b7
|
Provenance
The following attestation bundles were made for keepomize-0.1.2-py3-none-any.whl:
Publisher:
release.yml on nathanic/keepomize
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keepomize-0.1.2-py3-none-any.whl -
Subject digest:
30ab270c813e09a56391e563d5ac4ee1755d56dda4486706834bcbcc0362649f - Sigstore transparency entry: 393326808
- Sigstore integration time:
-
Permalink:
nathanic/keepomize@23e562a6095c8c78cf8b39195d1d26e651426389 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/nathanic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@23e562a6095c8c78cf8b39195d1d26e651426389 -
Trigger Event:
workflow_dispatch
-
Statement type: