Certificates and secrets
External Secrets Operator
1.What is ESO ?
ESO reads secrets from a vault or cloud secret manager (AWS, GCP, Azure, Vault...) and keeps a normal Kubernetes Secret in sync with them.
Git holds only pointers to secrets, never the values. Pods stay unchanged, they still mount a normal Secret.
Latest : v2.12.0 (CRDs use external-secrets.). CNCF Sandbox project.
In Simple Words
ESO fetches secrets from outside the cluster and turns them into Kubernetes Secrets, then keeps them fresh.
Vault -> ESO -> Secret -> Pod
2.Why it exists ?
- Secrets in K8s are only base64. Committing them to Git leaks credentials.
- The real source of truth lives in AWS, GCP, Azure or Vault. Copying values by hand goes stale.
- Rotating a secret means someone must update every cluster.
Fix : declare WHERE the secret lives in Git, and a controller fetches and refreshes it.
Key Points
- Declarative, no values in Git
- Re-fetches every refreshInterval
- Many backends, one API
- Output is a plain Secret
- Templating reshapes values
- PushSecret goes the other way
- Generators create values
- Works with Flux/Argo (just YAML)
3.Parts of ESO
- ControllerMain operator. Reconciles ExternalSecret and PushSecret, calls providers, writes Secrets.
- WebhookValidates the ESO CRDs (own deployment).
- Cert-controllerManages TLS certs for the webhook (own deployment).
- GeneratorsMake values: Password, UUID, SSHKey, ECR/GCR/ACR tokens and more.
Install Order
- Install ESO with Helm
- Create a store with auth
- Create an ExternalSecret
- Controller writes the Secret
- Pod mounts the Secret
- Refresh loop keeps it current
4.How the Sync Works
Reconcile Loop
- Watch ExternalSecret
- Resolve store
- Fetch remote data
- Apply template
- Write Secret
- Wait refreshInterval, repeat from 3
Ready=True on success, SecretSyncedError on failure.
In short : ESO pulls secrets from an external provider and keeps a normal Kubernetes Secret fresh, so Git never holds a value.
1.ESO Kinds + Store Scoping
A SecretStore only works in its own namespace. A ClusterSecretStore is shared, so restrict it with conditions. Tip : one SecretStore per namespace, or one shared ClusterSecretStore.
| Kind | Scope | Purpose |
|---|---|---|
| SecretStore | Namespaced | Provider config and auth |
| Cluster | Cluster | Shared provider config |
| ExternalSecret | Namespaced | Fetch remote data into a Secret |
| Cluster | Cluster | ExternalSecrets in many namespaces |
| PushSecret | Namespaced | Push Secret to provider |
| Cluster | Cluster | PushSecret across namespaces |
2.Example ExternalSecret + Gotchas
kind: ExternalSecret
metadata: {name: db-creds}
spec:
refreshInterval: 1h
secretStoreRef: {name: vault, kind: SecretStore}
target: {name: db-creds, creationPolicy: Owner}
data:
- secretKey: password
remoteRef: {key: prod/db, property: password}
Gotchas
- Store must be Ready first
- Env vars need a reloader, files refresh
- Prefer workload identity (IRSA)
- Low refreshInterval hits rate limits
- Owner policy : delete ES, Secret goes too
- Migrate v1beta1 / v1alpha1 to v1
3.ESO vs Plain Secret vs CSI Driver
| Source of truth | Creates K8s Secret | Rotation | Pod changes | How it works | |
|---|---|---|---|---|---|
| Plain Secret | In cluster | Manual | Manual | None | Static |
| ESO | External provider | Yes, automatic | Every refresh | None | Controller + CRDs |
| Secrets Store CSI | External provider | Optional (sync) | Mount rotation | CSI volume in Pod | Node driver |
4.ESO Commands
| Command | Description | Example |
|---|---|---|
helm install external-secrets external-secrets/ | Install operator + CRDs--set installCRDs=false | --set installCRDs=false |
kubectl get externalsecret -A | List, with sync statuskubectl get es -n app | kubectl get es -n app |
kubectl describe externalsecret <name> | Conditions + eventskubectl describe es db-creds | kubectl describe es db-creds |
kubectl get secretstore, | Check stores are Readykubectl get css | kubectl get css |
kubectl -n external-secrets logs deploy/ | Controller logsadd -f to follow | add -f to follow |
kubectl annotate es <name> force-sync=$(date +%s) --overwrite | Force immediate refreshes = externalsecret | es = externalsecret |
In short : Pick a namespaced SecretStore or a shared ClusterSecretStore, point an ExternalSecret at it, and check stores are Ready first. Unlike the CSI driver, Pods need no changes.