For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Record and field names below (for example database-credentials, tls-cert, Production/Databases) are illustrative - create matching records in your Shared folder that is shared to Keeper Secrets Manager Application, or change the annotations to point at your own records.

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-sidecar

Database 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.

You can also reference a folder by UID with keeper.security/folder-uid.

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).

Last updated

Was this helpful?