Generate Kubernetes Secrets in-cluster: passwords, tokens, SSH keys. Declared next to your app; the values are never stored in Git.
Website: https://generatedsecrets.jabbas.eu
Write a GeneratedSecret next to your application; the operator creates the
Secret once and then leaves its values alone:
apiVersion: generatedsecrets.jabbas.eu/v1alpha1
kind: GeneratedSecret
metadata:
name: app-admin # the Secret gets the same name and namespace
spec:
fields:
- name: password # 32 random alphanumeric characters by default- Helm's
randAlphaNumwithlookupgenerates a new value under Argo CD andhelm template, becauselookupreturns nothing there. - Encrypting a password with SOPS (Secrets OPerationS) or Sealed Secrets adds key management when no human needs to know the password.
- A pipeline that exists only to generate a key is a pipeline to maintain.
The one promise: a value changes only when you decide — you change its definition, delete the Secret (or one key), or configure a rotation. It does not change when the operator restarts or is upgraded, when its cache is lost, or when you re-apply the same manifest.
You need kind, Helm 4 and kubectl; no clone is needed. The kind image
below runs Kubernetes 1.34, the oldest supported version.
kind create cluster --image kindest/node:v1.34.11@sha256:44e222ee2132dab25ff87301682f89eb82c7880ea3a1bf543bfe9708fd08d67d
helm repo add jabbas https://jabbas.github.io/helm-charts
helm repo update jabbas
helm install generated-secrets-operator jabbas/generated-secrets-operator --version 0.2.1 --namespace generated-secrets-system --create-namespace --wait
kubectl apply -f - <<'EOF'
apiVersion: generatedsecrets.jabbas.eu/v1alpha1
kind: GeneratedSecret
metadata:
name: app-admin
spec:
deletionPolicy: Retain
data:
username: admin
fields:
- name: password
EOF
kubectl wait --for=condition=Ready gensecret/app-admin --timeout=60s
kubectl get secret app-admin -o jsonpath='{.data.password}' | base64 -d; echoRestart the operator and read the password again; it stays the same:
kubectl rollout restart deployment/generated-secrets-operator -n generated-secrets-system
kubectl rollout status deployment/generated-secrets-operator -n generated-secrets-system
kubectl get secret app-admin -o jsonpath='{.data.password}' | base64 -d; echoClean up:
kind delete clusterThe HTTP chart repository is not signed; for the cosign-signed chart and how to verify it, see Installation.
This operator is for secrets a machine can invent: passwords, tokens, random keys, SSH key pairs, basic-auth credentials. Other tools fit other jobs:
| Tool | Notes |
|---|---|
| Sealed Secrets, SOPS | Encrypt values a human already has, to commit them to Git. Right for externally issued secrets; for machine-invented ones they add key management for no benefit. |
| External Secrets Operator | Syncs secrets from an external store (for example AWS Secrets Manager); right when that store is the source of truth. Its generators say "Every invocation produces a new set of values"; stable values need three settings per object (refreshPolicy: CreatedOnce, target.immutable: true, creationPolicy: Orphan), and by default it runs three components (controller, webhook, certificate controller). Here stable values are the default, and deletionPolicy: Retain lets a re-created GeneratedSecret adopt its Secret. |
| HashiCorp Vault, OpenBao | A full secrets platform; heavy if you need only a few generated passwords. |
Helm randAlphaNum + lookup |
lookup returns nothing during helm template and client dry-run, and Argo CD does not support it, so the value is regenerated. |
| mittwald/kubernetes-secret-generator | The best-known earlier generator: annotation-driven, on plain Secrets. Latest release v3.4.1 (August 2025); the one before is from April 2022. |
| Carvel secretgen-controller | Maintained, with a broader scope (secret export and import across namespaces, certificates); suits Carvel users. |
When not to use Generated Secrets Operator:
- The secret is issued by someone else (a vendor API key, another team's password).
- The value must be known before deployment, or be identical across clusters.
- The values must survive losing the cluster. They live only in the cluster (in etcd, the Kubernetes data store); back up the Secrets, for example with Velero.
Generated values are ordinary Secrets: readable with get secrets, and
unencrypted in etcd unless encryption at rest is enabled (see
Security). They come from the operating system's
cryptographically secure random number generator.
- Safe by default. Values are generated once and stay stable; see the behaviour table.
- Three kinds of secret, one per
GeneratedSecret:fields(random strings, tokens and encoded random bytes),sshKeyPair(ed25519, RSA or ECDSA) andbasicAuth(username, password and a bcrypthtpasswdline). - Per-key control. Length, character set, excluded characters, minimum counts per character class, prefix and suffix; or N random bytes in hex, base64, base64url or base32.
- Optional scheduled rotation (
rotation.interval); manual rotation by deleting the Secret. deletionPolicy:Delete(default, garbage-collected with theGeneratedSecret) orRetain(the Secret survives; a re-createdGeneratedSecretadopts it and keeps its values).- Mistakes surface where you look. A bad manifest is rejected at
kubectl apply/helm installtime by the CRD (custom resource definition) schema and CEL (Common Expression Language) rules; runtime problems appear instatus.conditionsand Events. - Least privilege. No
deleteon Secrets, only metadata of managed Secrets is cached, values never reach logs, Events, status or metrics, and the operator never touches a Secret it did not create. Cluster-wide or per-namespace RBAC (role-based access control; a real boundary). - Production packaging. Multi-arch image (
linux/amd64,linux/arm64), Helm chart (also published as an OCI (Open Container Initiative) artifact), leader election for high availability, Prometheus metrics, Pod Securityrestricted; signed releases, see Status.
The API is generatedsecrets.jabbas.eu/v1alpha1. Defaults and the fingerprint
format are frozen for this version, so upgrades never rotate your credentials.
Breaking changes before v1beta1 are possible but are always called out in the
changelog. Releases are cosign-signed and carry an SBOM
(software bill of materials). Every release is promoted from a release
candidate that passed a test on a real cluster (0.2.0:
report). Supported Kubernetes: 1.34
and newer.
The project was renamed from SecretSpec Operator in 0.2.0, a breaking change; see Moving from 0.1.x and ADR (architecture decision record) 0006.
- Templates and derived keys
- Namespace scoping by label selector
- Additional generators
- The
v1beta1API
New here? Issues labelled
good first issue
are a good place to start.
| Document | Content |
|---|---|
| Installation | Install, upgrade, uninstall, values, scope modes, mirrors, CRD lifecycle, signature verification |
| API reference | Every field, default and validation; the generated Secret; behaviour table |
| Operations | Rotation, reloading consumers, deletionPolicy, troubleshooting, metrics, logging |
| Security | Threat model, RBAC, redaction guarantees, release signing and SBOM |
| Examples | Seven copy-paste GeneratedSecrets |
| Fingerprint format | The frozen format that decides when a value is regenerated |
| Development | Building, testing and running the operator locally |
| Contributing | What is welcome, what will not be accepted, how to send a change |
| Security policy | How to report a vulnerability privately; supported versions |
Bug reports, fixes, features and documentation improvements are welcome. Read CONTRIBUTING.md first; for a new feature, open an issue with the YAML you would like to write before you write code.
Apache-2.0; see LICENSE and NOTICE.
Generated Secrets Operator was inspired by mittwald/kubernetes-secret-generator.
