Course contentsShow
← Cloud and Infrastructure
Lesson 1280 of 2,98925. Kubernetes Configuration and SecretsFree lesson

ExternalSecret Resource

Defining ExternalSecret resources to fetch secrets from external stores and sync them as Kubernetes Secrets.

ExternalSecret Resource

What You'll Learn

You'll learn how to define an ExternalSecret resource that automatically fetches secrets from external stores and syncs them into Kubernetes Secrets.

What Is an ExternalSecret Resource?

Now that you've set up your SecretStore or ClusterSecretStore (which connects Kubernetes to your external secret manager), the ExternalSecret is the resource that actually requests specific secrets and brings them into your cluster.

Think of it like this: if the SecretStore is your library card that grants access, the ExternalSecret is your request slip for a specific book. You tell Kubernetes which secret to fetch, where to get it from, and what to name it once it arrives.

How It Works

An ExternalSecret resource specifies:

  • Which SecretStore to use (the connection to your external provider)
  • Which secret(s) to fetch (by key/path in the external store)
  • What Kubernetes Secret to create (the target name and namespace)

The External Secrets Operator watches ExternalSecret resources, retrieves the data from your external store, and creates or updates a standard Kubernetes Secret automatically. When the external secret changes, the operator can refresh the Kubernetes Secret accordingly.

Basic Structure

apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: my-app-secret
spec:
  secretStoreRef:
    name: vault-backend
    kind: SecretStore
  target:
    name: app-credentials
  data:
    - secretKey: username
      remoteRef:
        key: /path/to/secret
        property: user

This fetches the user property from /path/to/secret in your external store and creates a Kubernetes Secret named app-credentials with a key username.

Key Takeaway:
ExternalSecret resources define which secrets to fetch from external stores and automatically sync them as native Kubernetes Secrets, bridging external secret management with your cluster.