Sealed Secrets on Kestrel
Kestrel runs the Sealed Secrets controller sealed-secrets-controller (v0.27.1, Helm chart 2.16.1) in the sealed-secrets namespace. You encrypt a Secret with kubeseal against the controller’s public certificate and commit the resulting SealedSecret. When it is applied, the controller decrypts it into a Secret with the same name in the same namespace.
Keys: the controller generates a new sealing key every 30 days and keeps the old ones, so existing SealedSecrets keep decrypting and you never re-seal because of a key change. New seals use the newest key. Only the controller holds the private keys.
Install kubeseal
Section titled “Install kubeseal”Any kubeseal release 0.27 or newer works. It is a standalone binary, not a kubectl plugin.
brew install kubesealUse brew install kubeseal with Linuxbrew, or download a pinned version from the releases page:
KUBESEAL_VERSION='0.27.1'curl -OL "https://github.com/bitnami-labs/sealed-secrets/releases/download/v${KUBESEAL_VERSION}/kubeseal-${KUBESEAL_VERSION}-linux-amd64.tar.gz"tar -xzf "kubeseal-${KUBESEAL_VERSION}-linux-amd64.tar.gz" kubesealsudo install -m 755 kubeseal /usr/local/bin/kubesealscoop install kubesealSeal and deploy a secret
Section titled “Seal and deploy a secret”1. Fetch the certificate
Section titled “1. Fetch the certificate”kubeseal --controller-namespace sealed-secrets --fetch-cert > kestrel-pub-cert.pemThis uses your normal kubectl context (kubelogin). --controller-namespace sealed-secrets is required because kubeseal defaults to kube-system. The default controller name already matches.
The certificate is public. Sealing with --cert needs no cluster access, so CI runners can use a copy of it (--cert also accepts an HTTPS URL). Because old keys are kept, an older copy still works, but re-fetch it now and then so new seals use the current key.
2. Seal
Section titled “2. Seal”The Secret’s name and namespace must be the final ones: the default scope binds the ciphertext to both (see Scope). Generating the Secret in a pipe keeps the plaintext off disk:
kubectl create secret generic db-password -n <tenant>-prod \ --from-literal=password='s3cr3t-value' --dry-run=client -o yaml \ | kubeseal --cert kestrel-pub-cert.pem --format yaml > sealedsecret.yamlIf you write a Secret manifest by hand instead, seal it, then delete secret.yaml. Never commit it.
kubeseal --cert kestrel-pub-cert.pem --format yaml < secret.yaml > sealedsecret.yaml3. Commit, or apply
Section titled “3. Commit, or apply”The output is safe to commit. Add the sync-wave annotation so ArgoCD applies the SealedSecret before the workloads that read the derived Secret:
apiVersion: bitnami.com/v1alpha1kind: SealedSecretmetadata: name: db-password namespace: <tenant>-prod annotations: argocd.argoproj.io/sync-wave: "-1" # add thisspec: encryptedData: password: AgBy3i4OJSWK+PiTySYZZA9rO43cGDEq4kf8w... template: metadata: name: db-password namespace: <tenant>-prod type: OpaqueCommit it next to the workload that uses it, and ArgoCD applies it. Without ArgoCD, run kubectl apply -f sealedsecret.yaml.
4. Verify
Section titled “4. Verify”kubectl get sealedsecret,secret -n <tenant>-prodThe Secret appears within a few seconds. Consume it as usual (envFrom.secretRef or env[].valueFrom.secretKeyRef).
| Scope | Flag | Ciphertext bound to | Rename or move without re-sealing? |
|---|---|---|---|
| strict (default) | none | name and namespace | No |
| namespace-wide | --scope namespace-wide | namespace | Rename only |
| cluster-wide | --scope cluster-wide | nothing | Yes |
Use strict. Every tenant shares the controller, so anyone who obtains a cluster-wide SealedSecret (from a public repo, for example) can apply it in their own namespace and read the result. A strict one decrypts only under the name and namespace it was sealed for. Moving a secret from <tenant>-dev to <tenant>-prod means sealing it again.
Update a value
Section titled “Update a value”There is no in-place edit. Re-run the seal command with the new value, commit, and push. To replace one key in an existing SealedSecret, encrypt just that value and paste the output into spec.encryptedData.<key>. Raw mode carries no metadata, so pass the SealedSecret’s exact namespace and name:
echo -n 'new-s3cr3t-value' | kubeseal --raw --cert kestrel-pub-cert.pem \ --namespace <tenant>-prod --name db-passwordTroubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
kubeseal fails fetching the certificate: cannot get sealed secret service: services "sealed-secrets-controller" is forbidden, or another forbidden | Missing --controller-namespace sealed-secrets, the wrong context, an expired kubelogin session, or no cluster access (CI) | Add the flag and confirm kubectl get ns works. In CI, seal with --cert. |
No Secret appears; kubectl describe sealedsecret <name> shows no key could decrypt secret | The name or namespace differs from the sealed values, or it was sealed with another cluster’s certificate | Fetch Kestrel’s certificate and re-seal with the final name and namespace. |
kubectl describe sealedsecret shows Resource "<name>" already exists and is not managed by SealedSecret | A plain Secret with that name already exists | Delete it, or annotate it sealedsecrets.bitnami.com/managed: "true" so the controller takes it over. |
Derived Secret is OutOfSync or pruned in ArgoCD | The Secret is also in Git | Remove it from Git. |