External Secrets Operator (ESO) and sidecar injection

External Secrets Operator (ESO) and sidecar injection

Eliminate secret management headaches. Learn to integrate your cluster with AWS Secrets Manager, HashiCorp Vault, and Google Secret Manager using the External Secrets Operator.

External Secrets: The Cloud-Native Way to Manage Jewels

In the previous lessons, we've mastered how to use Kubernetes Secrets. But there is a dirty secret in the Kubernetes world: Storing secrets in Kubernetes is often a bad idea.

If you store a secret in K8s, it ends up in the etcd database. Even if you encrypt it, you are still responsible for rotating those secrets, managing access to them, and ensuring they don't leak into your Git repository. In an enterprise environment, your "Source of Truth" for secrets should be a dedicated, hardened vault like AWS Secrets Manager, Google Secret Manager, or HashiCorp Vault.

How do we bridge the gap? How do we get a secret from AWS into our FastAPI pod effortlessly?

The answer is the External Secrets Operator (ESO). In this lesson, we will master the world of "Secret Syncing." We will learn how to use the SecretStore and ExternalSecret resources to create a hands-off, ultra-secure pipeline for our most sensitive application data.


1. The Core Problem: The GitOps Dilemma

When using Infrastructure as Code (Module 4), you want every part of your cluster defined in Git. But you CANNOT put your actual production password in Git—not even if it's Base64 encoded.

The Standard (But Painful) Solution:

You manually run kubectl create secret for every new environment.

  • Problem: This is manual, error-prone, and doesn't scale. If you have 50 microservices across 5 clusters, you have to run 250 commands every time you rotate a key.

The ESO Solution:

You put a "Placeholder" in Git (an ExternalSecret resource). This placeholder tells K8s: "Go to AWS Secrets Manager, find the key named prod/db/pass, and keep it in sync with a K8s secret named db-pass."


2. The Two Components of ESO

To make this magic work, we use two Custom Resource Definitions (CRDs):

  1. SecretStore: Defines where the secrets live. It contains the authentication logic to talk to AWS or Vault.
  2. ExternalSecret: Defines what to fetch. It maps a remote key name to a local Kubernetes secret name.

3. Defining a SecretStore (The Connection)

Think of this as the "Connector." Here is how we connect a namespace to AWS Secrets Manager:

apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
  name: aws-secrets-connector
spec:
  provider:
    aws:
      service: SecretsManager
      region: us-east-1
      auth:
        jwt: # Uses IAM Roles for Service Accounts (IRSA)
          serviceAccountRef:
            name: secrets-reader-sa 

4. Defining an ExternalSecret (The Sync)

Once the connection is established, we tell K8s to "Pull" the data.

apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: db-credentials-sync
spec:
  refreshInterval: 1h # Check for updates every hour
  secretStoreRef:
    name: aws-secrets-connector
    kind: SecretStore
  target:
    name: local-db-secret # THE K8s SECRET WE WANT TO CREATE
  data:
  - secretKey: password # The key inside K8s
    remoteRef:
      key: prod/database/password # The key in AWS

The Result: ESO creates a standard Kubernetes Secret named local-db-secret. Your FastAPI app can now mount it as a volume (Lesson 7.2) without ever knowing that the secret actually lives in AWS!


5. Visualizing the External Secret Lifecycle

graph LR
    Cloud["AWS Secrets Manager (Source)"] -- "Encrypted Pull" --> ESO["External Secrets Operator"]
    ESO -- "Write / Sync" --> K8s["K8s Native Secret"]
    K8s -- "Mount" --> Pod["Application Pod"]
    
    style ESO fill:#f96,stroke:#333
    style Cloud fill:#9cf,stroke:#333

6. Rotation: Auto-Updating Applications

One of the best features of ESO is the refreshInterval.

  1. Your Security team rotates the password in AWS.
  2. ESO sees the change an hour later.
  3. ESO updates the Kubernetes Secret.
  4. Because our Pod mounted the secret as a Volume (Lesson 7.2), the file inside the pod updates automatically. End-to-End Zero-Touch Rotation.

7. AI Implementation: Global API Key Management

If you are running a globally distributed AI application—with clusters in New York, London, and Tokyo—managing your OpenAI or Anthropic API keys is a nightmare.

The Professional Global Strategy:

  1. Store your API keys in a single Global Secret Vault (like AWS Secrets Manager in a central region).
  2. Install ESO in every Kubernetes cluster across the world.
  3. Point all clusters to that single source of truth. Result: You update your key in ONE place, and your entire global AI network is updated automatically within the hour.

8. Summary and Key Takeaways

  • SecretStore: The definition of the remote secret provider (AWS, Vault, etc.).
  • ExternalSecret: The bridge that synchronizes remote data into a native K8s secret.
  • Security: Keeps your secrets out of Git and etcd (partially).
  • Automation: Enables automatic rotation of sensitive credentials.
  • Efficiency: Consolidates management for multi-cluster and multi-cloud environments.

Congratulations!

You have completed Module 7: Configuration and Secrets Management. You have moved from "Basic YAML" to "Enterprise-Grade Secret Orchestration." You are now capable of managing secrets for the most secure and scale-intensive companies in the world.

Next Stop: In Module 8: Scaling and Autoscaling, we will look at how we automatically grow our cluster to handle millions of users: HPA, VPA, and Cluster Autoscaler.


9. SEO Metadata & Keywords

Focus Keywords: External Secrets Operator tutorial K8s, AWS Secrets Manager Kubernetes integration, HashiCorp Vault K8s ESO, sync secrets from cloud to Kubernetes, SecretStore vs ExternalSecret, professional secret management K8s.

Meta Description: Take your secret management to the next level with the External Secrets Operator. Learn how to synchronize sensitive data from professional vaults like AWS and HashiCorp into your Kubernetes cluster, enabling automated rotation and enterprise-grade security.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn