Sub topic 4
Connecting to a provider with a SecretStore
This chapter assumes you can read Kubernetes YAML and use kubectl, and that ESO is already installed in your cluster. You also need a general idea of what a cloud secret manager does. Here the example provider is AWS Secrets Manager.
What a SecretStore is
A SecretStore is a namespaced custom resource that tells ESO how to reach one external secret provider. It holds the provider type, the region or endpoint, and the authentication method. It does not hold any secret values.
An ExternalSecret points at a store by name. The controller reads the store, signs in to the provider, and fetches the values. The store is the connection. The ExternalSecret is the request.
A SecretStore for AWS Secrets Manager
The following store lives in the app namespace. It uses the web identity of the eso-reader ServiceAccount, which on EKS is IRSA (IAM Roles for Service Accounts). No access keys appear in the manifest.
apiVersion: external-secrets.io/v1
kind: SecretStore
metadata:
name: aws-store
namespace: app
spec:
provider:
aws:
service: SecretsManager
region: eu-west-1
auth:
jwt:
serviceAccountRef:
name: eso-readerOlder ESO releases use apiVersion: external-secrets.io/v1beta1. Run kubectl api-versions | grep external-secrets to see which one your cluster serves.
The fields under spec.provider.aws mean the following.
| Field | Purpose |
|---|---|
| `service` | Which AWS service to read, here `SecretsManager`. |
| `region` | The AWS region that holds the secrets. |
| `auth.jwt.serviceAccountRef` | The ServiceAccount whose token is exchanged for an IAM role. |
Because this is a SecretStore, the ServiceAccount is looked up in the store's own namespace. The eso-reader ServiceAccount must therefore exist in app and carry the IRSA annotation for an IAM role that can read the secrets.
Checking that the store works
Apply the manifest, then inspect the store.
kubectl apply -f secretstore.yaml
kubectl get secretstore aws-store -n appThe STATUS column should show Valid and READY should be True. ESO validates the connection when it reconciles the store. If the status is not valid, run kubectl describe secretstore aws-store -n app and read the conditions and events.
Common errors
- Wrong namespace. A
SecretStorecan only be referenced byExternalSecretobjects in the same namespace. AnExternalSecretin another namespace reports that the store was not found. - Missing ServiceAccount. If
eso-readerdoes not exist in the store's namespace, authentication fails. - Missing IAM permissions. The role needs actions such as
secretsmanager:GetSecretValueon the secrets you want. Without them the store may look healthy, but theExternalSecretfails when it fetches a value. - Wrong region. A secret that exists in another region is reported as not found.
- Wrong API version. Using
v1on an older ESO release fails because the CRD does not serve that version.
When to choose a SecretStore
Use a SecretStore when one team or namespace owns its own provider connection and credentials. This keeps the blast radius small, because a compromised namespace can reach only what its store allows. If many namespaces need the same provider, a ClusterSecretStore avoids duplicating configuration. That resource has its own chapter.
Exercise
An ExternalSecret in namespace team-a references a SecretStore named aws-store that exists only in namespace app. What happens, and how do you fix it?
Show answer
The ExternalSecret fails because a SecretStore is namespaced and can only be referenced from its own namespace, so the store is reported as not found. Fix it by creating a SecretStore in team-a (with its own ServiceAccount and IAM role), or by using a ClusterSecretStore that allows team-a.