Skip to content

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.

Any kubeseal release 0.27 or newer works. It is a standalone binary, not a kubectl plugin.

Terminal window
brew install kubeseal
Terminal window
kubeseal --controller-namespace sealed-secrets --fetch-cert > kestrel-pub-cert.pem

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

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:

Terminal window
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.yaml

If you write a Secret manifest by hand instead, seal it, then delete secret.yaml. Never commit it.

Terminal window
kubeseal --cert kestrel-pub-cert.pem --format yaml < secret.yaml > sealedsecret.yaml

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/v1alpha1
kind: SealedSecret
metadata:
name: db-password
namespace: <tenant>-prod
annotations:
argocd.argoproj.io/sync-wave: "-1" # add this
spec:
encryptedData:
password: AgBy3i4OJSWK+PiTySYZZA9rO43cGDEq4kf8w...
template:
metadata:
name: db-password
namespace: <tenant>-prod
type: Opaque

Commit it next to the workload that uses it, and ArgoCD applies it. Without ArgoCD, run kubectl apply -f sealedsecret.yaml.

Terminal window
kubectl get sealedsecret,secret -n <tenant>-prod

The Secret appears within a few seconds. Consume it as usual (envFrom.secretRef or env[].valueFrom.secretKeyRef).

ScopeFlagCiphertext bound toRename or move without re-sealing?
strict (default)nonename and namespaceNo
namespace-wide--scope namespace-widenamespaceRename only
cluster-wide--scope cluster-widenothingYes

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.

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:

Terminal window
echo -n 'new-s3cr3t-value' | kubeseal --raw --cert kestrel-pub-cert.pem \
--namespace <tenant>-prod --name db-password
SymptomCauseFix
kubeseal fails fetching the certificate: cannot get sealed secret service: services "sealed-secrets-controller" is forbidden, or another forbiddenMissing --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 secretThe name or namespace differs from the sealed values, or it was sealed with another cluster’s certificateFetch 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 SealedSecretA plain Secret with that name already existsDelete it, or annotate it sealedsecrets.bitnami.com/managed: "true" so the controller takes it over.
Derived Secret is OutOfSync or pruned in ArgoCDThe Secret is also in GitRemove it from Git.