Examples
Complete, runnable examples for the Kubernetes Injector integration in Keeper Secrets Manager
These are complete, runnable examples for the Kubernetes Injector. Each one assumes you have already installed the injector and created the KSM authentication secret (keeper-credentials) as described on that page.
Quick check: inject a secret into a Pod
The fastest way to confirm the injector is working - fetch a record to a file and read it. The below .yaml configuration file demonstrates the feature.
apiVersion: v1
kind: Pod
metadata:
name: hello-secrets
annotations:
keeper.security/inject: "true"
keeper.security/ksm-config: "keeper-credentials"
keeper.security/secret: "demo-secret"
spec:
containers:
- name: app
image: busybox:1.36
command: ["sh", "-c", "cat /keeper/secrets/demo-secret.json && sleep 3600"]kubectl logs hello-secrets # prints the record JSON
kubectl get pod hello-secrets -o jsonpath='{.spec.containers[*].name}' # includes keeper-secrets-sidecarDatabase credentials as a file
The default mode: the record is written as JSON to /keeper/secrets/, and the app reads it.
Render a .env file
Use the config block to choose an output format. Here the record is rendered as a .env file the app can source.
Build a connection string with a template
Go templates (with Sprig functions) turn record fields into any format - here a Postgres URL.
Inject as environment variables
For legacy apps that only read env vars. Field names become uppercased keys; add a prefix and fetch once at startup (env vars can't change without a restart).
Create a Kubernetes Secret for a Deployment
When a workload needs a native Secret (for secretKeyRef, envFrom, or a Secret volume), have the injector create one from the record.
TLS certificate and key for NGINX
Download file attachments from a Keeper record to a path your app mounts.
Inject every secret in a folder
Fetch all records in a Keeper folder - one file per record under the output path.
Extract a single field with Keeper Notation
Write just one field to a precise path using Keeper Notation. Notation is parsed by the per-secret keeper.security/secret-<name> annotation (the plain keeper.security/secret annotation always treats its value as a record title).
Automatic rotation
In sidecar mode the agent re-fetches on an interval and rewrites the files in place - no Pod restart. Apps that re-read the file pick up the new value automatically.
More examples and Github Source
The injector's GitHub repository has a full catalog of runnable examples (web demos, databases, rotation dashboards, resilience, cloud auth, and more).
View the Github Source
Last updated
Was this helpful?

