TL;DR: Stop relying on insecure base64-encoded Kubernetes secrets that complicate SOC2 compliance and cause secrets sprawl. This guide demonstrates how to architect automated, dynamic secret rotation by integrating AWS Secrets Manager with the External Secrets Operator (ESO). You will learn how to deploy ESO via Helm, authenticate it with AWS IAM Roles for Service Accounts (IRSA) so no static AWS keys live in the cluster, and handle the pod restart and rotation edge cases that the happy path hides.
Key Takeaways
- Replace insecure, base64-encoded native Kubernetes secrets with dynamic secret injection to eliminate secrets sprawl and simplify SOC2 compliance audits.
- Choose the External Secrets Operator (ESO) when applications already read credentials from environment variables, so they can keep using standard
envFromdeclarations without code changes. - The ESO Helm chart installs and manages its Custom Resource Definitions (
SecretStore,ClusterSecretStore,ExternalSecret) by default, and current releases serve them asexternal-secrets.io/v1. - Authenticate ESO to AWS Secrets Manager using IAM Roles for Service Accounts (IRSA) and OIDC instead of storing static AWS IAM access keys in your cluster.
- ESO still writes a native Kubernetes
Secret, so enable etcd encryption and tight RBAC, and pair it with a reloader or connection-retry logic for rotation.
Native Kubernetes secrets offer little protection by default. If your deployment pipelines involve checking base64-encoded strings into version control, injecting environment variables via CI/CD platforms, or relying on statically defined Secret manifests, your architecture is suffering from secrets sprawl.
The fundamental problem with native Kubernetes secrets is that they are merely encoded, not encrypted. Anyone with get permission on secrets in a namespace can read your database credentials, API keys, and third-party tokens.
The Base64 Illusion and the Cost of Secrets Sprawl
When you create a standard Kubernetes Secret, you are likely using a manifest that looks something like this:
apiVersion: v1
kind: Secret
metadata:
name: database-credentials
type: Opaque
data:
DB_PASSWORD: c3VwZXJzZWNyZXRwYXNzd29yZA== # "supersecretpassword"
To experienced engineers, this is a well-known risk. Base64 is an encoding mechanism designed for data transport, not a cryptographic protection mechanism.
Security Note: Even if you enable Encryption at Rest in etcd, this only protects the data on the physical disks of the control plane. An attacker, or a compromised pod whose service account can read secrets through the Kubernetes API, can still read the decrypted secret in plain text.
Secrets sprawl occurs when these static files are copied across developers' local environments, staging clusters, and Git repositories. When a developer leaves the company, or when an API key is inadvertently logged to Datadog or CloudWatch, tracking down every instance of that static secret becomes an incident response nightmare.
The SOC2 Nightmare and Rotation Friction
When preparing for SOC2 or ISO-27001 compliance, auditors commonly ask for evidence that credentials are managed and rotated according to your own documented policy. Neither framework prescribes a fixed interval, but many teams commit to rotating database passwords and third-party API keys every 30 to 90 days, and doing that by hand without downtime is hard.
If you use static .env files or native Kubernetes secrets injected via CI/CD, secret rotation becomes a friction-laden, manual process:
- Manually change the password in the database (e.g., AWS RDS).
- Update the CI/CD pipeline secrets (GitHub Actions, GitLab CI, etc.).
- Distribute the new credentials to developers for their local
.envfiles. - Run
kubectl apply -f new-secret.yaml. - Run
kubectl rollout restart deployment/my-api.
The result: a high risk of downtime and mismatched credentials during the rotation window.
The frustration peaks when a manual rotation fails, bringing down an entire microservice simply because a single pipeline job failed to inject the updated secret. We need a system where Kubernetes acts as a consumer of secrets, not the source of truth.
The Solution: External Secrets Operator (ESO) vs. Secrets Store CSI
To automate secret rotation, we must decouple secret storage from secret consumption.
There are two primary paradigms for securely managing secrets in AWS EKS:
- Secrets Store CSI Driver: Mounts secrets as file volumes directly inside the pod.
- External Secrets Operator (ESO): Fetches secrets from external APIs (like AWS Secrets Manager) and dynamically generates native Kubernetes
Secretobjects.
The CSI driver keeps secrets out of etcd unless you enable its optional sync-to-Secret feature, but applications typically need to read credentials from file paths instead of environment variables. ESO is often the easier fit for existing applications: it fetches the secret from AWS and creates a native Secret that your application can consume via standard envFrom declarations without code changes. The trade-off is that the value is stored in etcd again, so etcd encryption and RBAC on Secret objects still matter.
Let's install the External Secrets Operator (ESO) using Helm:
helm repo add external-secrets https://charts.external-secrets.io
helm repo update
helm install external-secrets \
external-secrets/external-secrets \
-n external-secrets \
--create-namespace
By default the chart installs and manages the Custom Resource Definitions (CRDs) as part of the release: SecretStore, ClusterSecretStore, and ExternalSecret, among others. Set installCRDs=false only if you manage CRDs separately; the ESO docs note the CRD bundle exceeds the client-side apply size limit, so out-of-band installs need kubectl apply --server-side. Pin the chart with --version in production so upgrades are deliberate.
Architecting Least Privilege with AWS IRSA
Before ESO can pull secrets from AWS Secrets Manager, it needs authorization. The anti-pattern here is to create an AWS IAM User, generate long-lived Access Keys, and store those keys in Kubernetes. This simply replaces one static secret with an even more powerful static secret.
Instead, we use IAM Roles for Service Accounts (IRSA). IRSA uses OpenID Connect (OIDC) to map a Kubernetes ServiceAccount directly to an AWS IAM Role.
First, we define an IAM Trust Policy that allows the ESO ServiceAccount in our EKS cluster to assume the IAM Role:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789012:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/EXAMPLED539D4633E53OSOMETHING"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"oidc.eks.us-east-1.amazonaws.com/id/EXAMPLED539D4633E53OSOMETHING:sub": "system:serviceaccount:external-secrets:external-secrets-sa",
"oidc.eks.us-east-1.amazonaws.com/id/EXAMPLED539D4633E53OSOMETHING:aud": "sts.amazonaws.com"
}
}
}
]
}
Next, we attach a permissions policy restricting this role to only read the specific secrets it needs from AWS Secrets Manager:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetResourcePolicy",
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret",
"secretsmanager:ListSecretVersionIds"
],
"Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:production/db/*"
}
]
}
Scoping the Resource to a path prefix such as production/db/* is what stops a compromised namespace from reading every secret in the account. If you want a second pair of eyes on IAM scoping across clusters, our DevOps and cloud deployment services cover this kind of review.
The IAM role ARN is then attached to the Kubernetes ServiceAccount with the eks.amazonaws.com/role-arn annotation:
apiVersion: v1
kind: ServiceAccount
metadata:
name: external-secrets-sa
namespace: external-secrets
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/external-secrets-reader
Bootstrapping the ClusterSecretStore
With ESO installed and IRSA configured, we must instruct the operator on how to connect to AWS. We achieve this by creating a ClusterSecretStore. This is a cluster-scoped resource, meaning any namespace can reference it (if you prefer strict namespace isolation, use a SecretStore instead).
apiVersion: external-secrets.io/v1
kind: ClusterSecretStore
metadata:
name: aws-secrets-manager
spec:
provider:
aws:
service: SecretsManager
region: us-east-1
auth:
jwt:
serviceAccountRef:
name: external-secrets-sa
namespace: external-secrets
Because we are using the jwt authentication method linked to our annotated ServiceAccount, no AWS credentials appear in this configuration. ESO requests a token for that ServiceAccount and exchanges it with AWS STS for temporary role credentials. For a ClusterSecretStore, the namespace field on serviceAccountRef is required. Older tutorials use external-secrets.io/v1beta1; current ESO releases serve v1, so update manifests when you upgrade.
Fetching and Synchronizing the ExternalSecret
Now for the core mechanism. We want to pull a JSON payload from AWS Secrets Manager (e.g., production/db/credentials) and map it into a native Kubernetes Secret.
We create an ExternalSecret manifest, which serves as the instruction manual for ESO.
apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: db-credentials-es
namespace: production-apps
spec:
refreshInterval: '1h' # The critical rotation interval
secretStoreRef:
name: aws-secrets-manager
kind: ClusterSecretStore
target:
name: db-credentials-native # Name of the standard K8s Secret it will create
creationPolicy: Owner
dataFrom:
- extract:
key: production/db/credentials
Production Tip:
refreshIntervalcontrols how often ESO polls the provider. With the defaultPeriodicrefresh policy, the reconciliation loop queries AWS Secrets Manager every hour and, if the value has changed, updates the nativedb-credentials-nativesecret in Kubernetes.creationPolicy: Owner(the default) makes theExternalSecretthe owner of that Secret, so deleting theExternalSecretalso deletes the Secret.
You can now map this dynamically generated secret into your application deployment exactly as you would with a static secret:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nodejs-backend
namespace: production-apps
spec:
replicas: 3
template:
spec:
containers:
- name: api
image: my-company/nodejs-backend:v2.4.1
envFrom:
- secretRef:
name: db-credentials-native # managed by ESO
Automating Rotation on the AWS Backend
The Kubernetes side now follows AWS automatically. The secret value itself still has to change, so the next step is automating rotation within AWS.
AWS Secrets Manager supports rotation schedules powered by AWS Lambda, using AWS-provided rotation function templates for Amazon RDS. When the schedule triggers, the Lambda function creates a new pending secret version, sets the new password on the database, tests it, and then promotes it to the current version. If RDS manages the master password for you (ManageMasterUserPassword), Secrets Manager uses managed rotation and you omit the Lambda ARN.
You can configure this via the AWS CLI by attaching a rotation schedule to your secret:
aws secretsmanager rotate-secret \
--secret-id production/db/credentials \
--rotation-lambda-arn arn:aws:lambda:us-east-1:123456789012:function:RotateRDSPassword \
--rotation-rules AutomaticallyAfterDays=30
Note that rotate-secret rotates immediately by default when you first set the schedule. Pass --no-rotate-immediately if you only want to register the schedule.
The Full Lifecycle in Action
- Day 30: AWS Secrets Manager triggers the Lambda function.
- The Lambda updates the RDS password and saves it to Secrets Manager.
- Within 1 Hour: ESO's
refreshIntervalis triggered. It fetches the new JSON payload from AWS. - ESO updates the
db-credentials-nativeKubernetes Secret. - Reloader (below) or your application's own retry logic picks up the new value.
Trade-offs and Production Safeguards
This architecture removes most copies of static secrets, but it introduces trade-offs you need to plan for.
1. The Pod Restart Problem
When ESO updates the underlying Kubernetes Secret, running pods do not automatically restart. Environment variables are injected only at pod boot time. Changing a database password usually does not kill existing connections, but any new connection a pod opens with the old password will fail, so connection pool churn or a database restart can surface as errors hours after rotation.
A common fix is to run a controller like Reloader by Stakater. Reloader watches for changes to ConfigMaps and Secrets and performs a rolling restart of the Deployments that opt in through annotations. For databases, the Secrets Manager "alternating users" rotation strategy further reduces the window, because the previous credentials stay valid until the next rotation.
# Add this annotation to the Deployment's top-level metadata
metadata:
annotations:
secret.reloader.stakater.com/reload: 'db-credentials-native'
2. AWS API Rate Limiting and Costs
AWS Secrets Manager bills API calls per 10,000 requests, on top of a monthly per-secret charge. If you set your refreshInterval to 1m (one minute) across 500 ExternalSecret resources, you are generating 720,000 API calls a day. That adds avoidable cost and can trigger throttling (ThrottlingException).
A 1-hour or 4-hour refreshInterval is usually enough, as long as the old credential stays valid for longer than that interval after rotation.
3. Fallback and Resilience
What happens if AWS Secrets Manager is unreachable or the IAM trust relationship breaks? ESO does not delete the native Secret when a refresh fails; the ExternalSecret reports Ready: False and the last synced value stays in the cluster, so pods can still start with the last known value. Alert on that condition, because a stale value will break once the next rotation lands. Also keep the default deletionPolicy: Retain, so keys removed at the provider are not removed from the Secret by surprise.
# Checking the status of your ExternalSecret integration
$ kubectl get externalsecrets -n production-apps
NAME STORE REFRESH INTERVAL STATUS READY
db-credentials-es aws-secrets-manager 1h SecretSynced True
By implementing the External Secrets Operator with AWS Secrets Manager, you remove most manual steps from the credential lifecycle. Developers no longer need production database passwords, CI/CD pipelines no longer transport them, and the Secrets Manager rotation history plus CloudTrail logs give auditors concrete evidence of when each secret was rotated.
Sources
- External Secrets Operator: Getting started (Helm install, CRD management)
- External Secrets Operator: AWS Secrets Manager provider and AWS authentication
- External Secrets Operator: ExternalSecret API (
creationPolicy,deletionPolicy,refreshPolicy) - AWS CLI reference: secretsmanager rotate-secret
- Stakater Reloader README
Need help building this in production?
SoftwareCrafting is a full-stack dev agency - we ship fast, scalable React, Next.js, Node.js, React Native & Flutter apps for global clients.
Get a Free ConsultationFrequently Asked Questions
Why are native Kubernetes secrets considered insecure by default?
Native Kubernetes secret values are base64-encoded, not encrypted, in the API. Anyone with permission to read secrets in a namespace, or a compromised pod whose service account has that permission, can decode them. Enabling etcd encryption at rest protects the stored data, but values are still returned in readable form through the Kubernetes API.
What is the difference between External Secrets Operator (ESO) and the Secrets Store CSI Driver?
The Secrets Store CSI Driver mounts external secrets as file volumes directly inside your pods, which often requires rewriting application code to read from file paths instead of environment variables. In contrast, ESO fetches secrets from external APIs like AWS Secrets Manager and dynamically generates native Kubernetes Secret objects. This allows applications to consume secrets via standard envFrom declarations without code changes, at the cost of storing the value in etcd.
How do I authenticate the External Secrets Operator with AWS without using static IAM access keys?
Use IAM Roles for Service Accounts (IRSA) to map a Kubernetes ServiceAccount directly to an AWS IAM Role. By leveraging OpenID Connect (OIDC), ESO can assume the necessary IAM Role to fetch credentials from AWS Secrets Manager without ever storing long-lived, static AWS access keys in your cluster.
How does integrating AWS Secrets Manager with Kubernetes help achieve SOC2 compliance?
SOC2 and ISO-27001 auditors look for evidence that you follow your own credential management and rotation policy. Keeping AWS Secrets Manager as the source of truth and letting ESO sync values into the cluster lets you run automated rotation schedules and point auditors at the rotation history. It also removes the manual steps of updating Kubernetes manifests and CI/CD variables, which is where most rotation mistakes happen.
