DevOps
DevOpsAdvanced

External Secrets Operator in Kubernetes: ClusterSecretStore, Rotation & GitOps Guide

Complete guide to External Secrets Operator (CNCF / Linux Foundation): ClusterSecretStore vs SecretStore, keyless GCP/AWS/Vault auth, templating v2, PushSecret, rotation with Reloader, and ESO vs Sealed Secrets vs CSI Driver.

Cover image: External Secrets Operator in Kubernetes: ClusterSecretStore, Rotation & GitOps Guide
Contents

Every Kubernetes team hits the same GitOps wall sooner or later. You wire up Argo CD or Flux, lock down kubectl apply in CI, and feel great about declarative infrastructure — until someone asks: “Where do we put the Postgres password and Stripe API key?”

Commit a standard Kubernetes Secret to Git, and your base64-encoded credentials live in repository history forever. Leave Secret creation out-of-band via manual kubectl commands, and your disaster recovery runbook breaks the moment a cluster is rebuilt.

External Secrets Operator in Kubernetes: Keyless Cloud Vault Sync via ClusterSecretStore

External Secrets Operator (ESO) — a vendor-neutral CNCF Sandbox project hosted under the Linux Foundation (accepted July 2022) — solves that gap cleanly. You commit an ExternalSecret manifest (which contains only references to secret names, never values) to Git, and ESO’s in-cluster controller pulls the actual values from Google Cloud Secret Manager, AWS Secrets Manager, HashiCorp Vault, or Azure Key Vault into native Kubernetes Secret objects.

(Setting up GitOps delivery first? See GitOps with Argo CD: Automated Kubernetes Deployments before wiring ESO into your ApplicationSet pipelines.)

1. How External Secrets Operator Works (And What It Does Not Do)

External Secrets Operator Architecture: External Secret Manager (GCP, AWS, Vault) via Workload Identity and ClusterSecretStore into Kubernetes Secrets and Pods
ESO reconciles ExternalSecret CRDs on a polling interval without ever storing plaintext secrets in Git.

ESO installs via Helm in under a minute and introduces two core Custom Resource Definitions (CRDs):

Terminal window
helm repo add external-secrets https://charts.external-secrets.io
helm upgrade --install external-secrets external-secrets/external-secrets \
-n external-secrets --create-namespace --set installCRDs=true
  1. SecretStore / ClusterSecretStore: Defines where the secrets live (GCP, AWS, Vault, Azure, 1Password, Doppler) and how ESO authenticates (Workload Identity, IRSA, Kubernetes auth).
  2. ExternalSecret: Lives in your app’s Git repo and maps specific keys from the store into a native Kubernetes Secret in that namespace on a refreshInterval.

2. ClusterSecretStore vs. SecretStore: Multi-Tenant Blast Radius

Choosing the wrong store scope is the most common ESO security mistake in production clusters.

SecretStore vs ClusterSecretStore in Multi-Tenant Kubernetes: Namespaced Isolation vs Cluster-Wide Shared Access
Use namespaced SecretStore per tenant for strict IAM isolation; restrict ClusterSecretStore with namespace selectors.
  • SecretStore (Namespaced — Safest Default): Lives inside one namespace (payments-prod) and uses that namespace’s Kubernetes ServiceAccount (bound via Workload Identity / IRSA to only payments-prod secrets in GCP/AWS). Even if a developer in staging compromises their namespace, they cannot reference payments-prod’s store.
  • ClusterSecretStore (Cluster-Scoped): Configured once by the platform team so any namespace can reference it. Great for shared platform certs or registry credentials — dangerous for app secrets unless you lock down spec.conditions (namespace labels/names) so arbitrary namespaces cannot pull production database passwords.

3. Production YAML: Keyless Auth (GCP, AWS & Vault)

Never store a GCP JSON key, Vault root token, or AWS AWS_ACCESS_KEY_ID inside a Kubernetes Secret to bootstrap ESO. Use Workload Identity Federation (GKE), IRSA (EKS), or Vault Kubernetes Auth.

Example A: GCP Secret Manager (SecretStore + Workload Identity)

gcp-secretstore.yaml
apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
name: gcp-secret-manager
namespace: payments-prod
spec:
provider:
gcpsm:
projectID: "prod-platform-1234"
auth:
workloadIdentity:
clusterLocation: europe-west3
clusterName: gke-prod-eu
serviceAccountRef:
name: eso-payments-sa # Annotated with iam.gke.io/gcp-service-account

Example B: AWS Secrets Manager (ClusterSecretStore with Namespace Guard)

aws-clustersecretstore.yaml
apiVersion: external-secrets.io/v1beta1
kind: ClusterSecretStore
metadata:
name: aws-prod-secrets
spec:
conditions:
- namespaces: ["payments-prod", "checkout-prod"] # Prevent cross-tenant reads
provider:
aws:
service: SecretsManager
region: eu-central-1
auth:
jwt:
serviceAccountRef:
name: eso-irsa-sa
namespace: external-secrets

Example C: HashiCorp Vault (SecretStore + Kubernetes Auth)

vault-secretstore.yaml
apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
name: vault-backend
namespace: payments-prod
spec:
provider:
vault:
server: "https://vault.internal:8200"
path: "secret"
version: "v2"
auth:
kubernetes:
mountPath: "kubernetes"
role: "payments-prod-role"
serviceAccountRef:
name: eso-payments-sa

4. Templating v2, Generators, and PushSecret

Basic guides stop at copying 1:1 key/value pairs. In real production apps, you often need to assemble connection strings, generate ephemeral tokens, or push cluster-born credentials back to a cloud vault.

Dynamic Formatting with template.engineVersion: v2

Instead of storing duplicate DATABASE_URL and DB_PASSWORD secrets in your vault, compose them inside the ExternalSecret:

db-externalsecret-template.yaml
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: postgres-credentials
namespace: payments-prod
spec:
refreshInterval: 1h
secretStoreRef:
name: gcp-secret-manager
kind: SecretStore
target:
name: postgres-credentials
creationPolicy: Owner # Deletes K8s Secret if ExternalSecret is pruned
template:
engineVersion: v2
data:
DATABASE_URL: "postgres://{{ .db_user }}:{{ .db_pass }}@pg-prod.internal:5432/payments?sslmode=require"
data:
- secretKey: db_user
remoteRef:
key: payments-db-user
- secretKey: db_pass
remoteRef:
key: payments-db-pass

Ephemeral Credentials (Generator CRDs) & PushSecret

  • Generator CRDs (generators.external-secrets.io/v1alpha1): Generate random Password values, UUIDs, ECRAuthorizationTokens, or VaultDynamicSecrets directly without pre-seeding static credentials.
  • PushSecret (external-secrets.io/v1alpha1): Reverses the flow — pushes a Kubernetes-generated Secret (such as a cert-manager TLS certificate or a Generator password) out into GCP Secret Manager, AWS Secrets Manager, or Vault so external services can consume it.

5. Secret Rotation & Troubleshooting in Production

Here is the trap that bites teams during their first automated secret rotation:

  1. You rotate the database password in GCP Secret Manager or Vault.
  2. Within refreshInterval (e.g. 1h), ESO updates the Kubernetes Secret postgres-credentials.
  3. Your running Pods still crash with authentication failed, because Kubernetes does not reload environment variables (envFrom) in running containers when a Secret changes.

Two ways to fix rotation cleanly:

  • For env / envFrom apps: Run Stakater Reloader in the cluster and annotate your Deployment with reloader.stakater.com/auto: "true" — it hashes Secret data and triggers a rolling restart whenever ESO writes a new version.
  • For zero-downtime apps: Mount the Secret as a volume file (kubelet updates mounted files roughly every 60 seconds, unless subPath is used!) and watch the file in your application.

Quick production troubleshooting checklist:

  • Check kubectl describe externalsecret <name> -n <ns> for SecretSyncedError — 90% of failures are missing IAM permissions (roles/secretmanager.secretAccessor on GCP or secretsmanager:GetSecretValue on AWS) or a blocked ClusterSecretStore namespace condition.
  • On large clusters (500+ ExternalSecret objects), avoid setting refreshInterval: 10s everywhere; 1h keeps cloud Secret Manager API quotas and billing predictable, while manual urgent rotations can be forced via annotation (force-sync=$(date +%s)).

6. ESO vs. Sealed Secrets vs. SOPS vs. Secrets Store CSI Driver

Comparison Matrix: External Secrets Operator vs Sealed Secrets vs SOPS vs Secrets Store CSI Driver
ESO wins when your source of truth is already a cloud secret manager and apps expect standard Kubernetes Secrets.
6. ESO vs. Sealed Secrets vs. SOPS vs. Secrets Store CSI Driver
Approach Governance Source of Truth Stored in Git? Rotation Effort Best Fit
External Secrets Operator CNCF / Linux Foundation Cloud Secret Manager / Vault References only (ExternalSecret) Automatic (refreshInterval) + Reloader Cloud-native K8s (GKE, EKS, AKS, Vault)
Bitnami Sealed Secrets Vendor-led OSS Encrypted YAML in Git Yes (asymmetric ciphertext) Manual re-seal per change Air-gapped / on-prem without Vault
Mozilla SOPS Community OSS Encrypted YAML in Git Yes (KMS/age ciphertext) Manual re-encrypt + commit Small teams using Flux native SOPS
Secrets Store CSI Driver Kubernetes SIG-Auth Cloud Secret Manager / Vault References (SecretProviderClass) Volume mount auto-sync Strict no-etcd compliance (memory-only tmpfs)

Bottom line: Pick Secrets Store CSI Driver only if compliance forbids secrets in etcd entirely (and you are willing to mount CSI volumes into every Pod). Pick Sealed Secrets or SOPS for small self-hosted clusters without a cloud secret manager. For production GKE, EKS, AKS, or Vault fleets running Argo CD or Flux, External Secrets Operator is the CNCF standard.

Sources

Frequently asked questions

Does External Secrets Operator eliminate Kubernetes etcd exposure?

No. ESO keeps secrets out of Git repositories, but by default it still materializes standard Kubernetes Secret objects inside etcd. Enable etcd envelope encryption at rest (such as Cloud KMS or AWS KMS) and restrict RBAC get/list/watch on secrets.

When should I use ClusterSecretStore vs SecretStore in multi-tenant clusters?

Use a namespaced SecretStore per team or namespace whenever tenants should only access their own cloud project or Vault path. ClusterSecretStore is cluster-scoped and convenient for shared platform credentials, but without strict conditions/namespace selectors any ExternalSecret in any namespace can reference it.

How does External Secrets Operator rotate secrets without leaving Pods with stale passwords?

ESO polls the external provider based on refreshInterval (for example 1h) and updates the Kubernetes Secret. Pods using env/envFrom keep the old value until restarted — deploy Stakater Reloader (reloader.stakater.com/auto: 'true') or mount secrets as files with application-level reload.

External Secrets Operator vs Secrets Store CSI Driver: which one breaks less in GitOps?

ESO is usually simpler for Argo CD and Flux workflows because applications still consume standard Kubernetes Secrets (envFrom, imagePullSecrets, TLS Secrets for Ingress/Gateway API) without needing CSI volume mounts in every Deployment.

From the community

Discussion on Mastodon & Bluesky

Replies to this article from the open web, pulled in live. No ads, no tracking scripts.

Loading replies …
Reply on MastodonReply on Bluesky

Reply there — it shows up here automatically.

ENDE