Sub topic 2
How External Secrets Operator works
This chapter assumes you know basic kubectl usage, Kubernetes Secrets and namespaces, and how to read YAML. It also assumes you know what a cloud secret manager such as AWS Secrets Manager or HashiCorp Vault does. You don't need to install anything yet.
The idea in one paragraph
External Secrets Operator (ESO) is a controller that runs in your cluster. It reads values from an external secret manager and writes them into ordinary Kubernetes Secrets. The source of truth stays in the secret manager. Git holds only small manifests that say which remote value to fetch and where to put it.
The custom resources
ESO adds its own resource types to the Kubernetes API. These are custom resource definitions (CRDs) in the external-secrets.io API group.
| Resource | Scope | Role |
|---|---|---|
| `SecretStore` | Namespace | Describes how to reach one provider and how to authenticate. Only ExternalSecrets in the same namespace can use it. |
| `ClusterSecretStore` | Cluster | Same job as a SecretStore, but ExternalSecrets in other namespaces can reference it. |
| `ExternalSecret` | Namespace | Says which remote values to read and what Kubernetes Secret to produce. |
A store holds the connection details. An ExternalSecret holds the request. Keeping them apart lets many ExternalSecrets share one store, and lets a platform team own the store while application teams own their requests.
What happens during a sync
The ESO controller watches ExternalSecret resources. For each one it runs this loop:
- Find the store named in
secretStoreRef. - Authenticate to the provider using the credentials or identity the store describes.
- Fetch the remote keys listed in
dataordataFrom. - Create or update the target Kubernetes Secret with those values.
- Record the result in the ExternalSecret's status.
- Wait for the
refreshIntervalto pass, then repeat from step 2.
The controller does the fetching. Your Pods never talk to the secret manager. They read a normal Kubernetes Secret, so existing workloads need no code changes.
A minimal example
This ExternalSecret asks for one property of the remote secret prod/db. It refers to a store named aws-store in the same namespace.
apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: db-credentials
namespace: app
spec:
refreshInterval: 1h
secretStoreRef:
name: aws-store
kind: SecretStore
target:
name: db-credentials
data:
- secretKey: password
remoteRef:
key: prod/db
property: passwordThe fields map to the loop above:
secretStoreRefselects the store, andkindsays whether it is aSecretStoreor aClusterSecretStore.remoteRefnames the remote secret (key) and a field inside it (property).secretKeyis the key to use inside the Kubernetes Secret.target.nameis the name of the Secret to create. If you omit it, ESO uses the ExternalSecret's name.
Things to keep in mind
- The result is still a plain Kubernetes Secret. Anyone who can read Secrets in that namespace can read the value, and it is stored in etcd. ESO removes secrets from Git, not from the cluster.
- The controller needs permission to read from the provider. That access is configured in the store, which later chapters cover.
- A sync is a poll. A change in the provider reaches the cluster at the next refresh, not instantly.
- The ExternalSecret reports problems in its status, such as a missing remote key or a failed login. You check it there first.
Exercise
A team lead wants one team to manage provider credentials while application teams only request values. Which ESO resources divide that work, and which one must live in the same namespace as the Secret it produces?
Show answer
The store (SecretStore or ClusterSecretStore) holds the provider connection and authentication, so the platform team owns it. Application teams write ExternalSecrets that reference the store. The ExternalSecret is namespaced and creates the target Secret in its own namespace.