---
title: "External Secrets Operator in Kubernetes: ClusterSecretStore, Rotation & GitOps Guide"
description: "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."
author: Aleksei Aleinikov
date: 2026-12-04
lang: en
tags: [external-secrets-operator, kubernetes-secrets, clustersecretstore, kubernetes, devops, gitops, argo-cd]
canonical: https://www.alekseialeinikov.com/en/blog/topics/devops/external-secrets-operator-kubernetes-secrets-manager-guide
source: alekseialeinikov.com
---

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

Every Kubernetes team hits the same GitOps wall sooner or later. You wire up [Argo CD or Flux](https://www.alekseialeinikov.com/en/blog/topics/devops/argo-cd-vs-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](https://media.alekseialeinikov.com/devops/d9f3a6c2e8b1/cover-1200.dba1a2821db5d020.webp)

**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](https://www.alekseialeinikov.com/en/blog/topics/devops/gitops-argo-cd-automated-kubernetes-deployments-2026) 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](https://media.alekseialeinikov.com/devops/d9f3a6c2e8b1/eso-architecture-flow-1200.e3dafb1b105518af.webp "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):

```bash
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`.

> [!WARNING]
> **The `etcd` Myth:** ESO keeps plaintext secrets **out of Git**, not out of `etcd`. Because ESO creates native Kubernetes `Secret` objects, anyone with `kubectl get secret -o yaml` in that namespace (or raw `etcd` snapshot access) can still read them. Always pair ESO with **KMS encryption at rest for `etcd`** and strict namespace RBAC.

## 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](https://media.alekseialeinikov.com/devops/d9f3a6c2e8b1/eso-clustersecretstore-vs-secretstore-1200.04d3b602993dd8d2.webp "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)

```yaml title="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)

```yaml title="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)

```yaml title="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`:

```yaml title="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, `UUID`s, `ECRAuthorizationToken`s, or `VaultDynamicSecret`s 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.

> [!TIP]
> **Watch `engineVersion: v2` key names:** If your remote secret key contains dashes (like `api-key`), reference it with `{{ index . "api-key" }}` in Go templates — `v2` immediately fails reconciliation on missing or invalid keys instead of silently rendering `<no value>`.

## 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](https://media.alekseialeinikov.com/devops/d9f3a6c2e8b1/eso-vs-sealed-secrets-csi-matrix-1200.751f2457e7f1d395.webp "ESO wins when your source of truth is already a cloud secret manager and apps expect standard Kubernetes Secrets.")

| 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

- [CNCF Landscape & Project Profile — External Secrets Operator (Linux Foundation)](https://www.cncf.io/projects/external-secrets-operator/)
- [External Secrets Operator — Official Documentation & API Reference](https://external-secrets.io/latest/)
- [External Secrets Operator — Advanced Templating v2 & PushSecret](https://external-secrets.io/latest/guides/templating/)
- [External Secrets Operator — Google Cloud Secret Manager & AWS Providers](https://external-secrets.io/latest/provider/google-secrets-manager/)
- [Kubernetes Documentation — Encrypting Confidential Data at Rest](https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/)
