Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Chapter 6Name in the course: Secrets in Git

Handle secrets in GitOps

GitOps puts everything in Git — but plain secrets must never be there. Three patterns solve it: encrypt the secret before commit (Sealed Secrets, SOPS), or reference it in an external store (External Secrets Operator).

  • 4 Lessons
  • 6 Commands

$ run as a normal user# run as root (or with sudo)

6.1

Know the options

Choose by where the secret's source of truth lives.

OptionIn GitDecrypted by
Sealed SecretsAn encrypted SealedSecretA controller in the cluster (its private key)
SOPS (+ age or cloud KMS)Encrypted values in normal YAMLFlux (built in) or Argo CD plugin
External Secrets OperatorOnly a reference (ExternalSecret)The operator fetches from Vault / Key Vault

6.2

Use Sealed Secrets

kubeseal encrypts with the cluster's public key; only the controller can decrypt.

helm install sealed-secrets sealed-secrets/sealed-secrets -n kube-system
kubectl create secret generic db -n shop --from-literal=password='S3cret!' --dry-run=client -o yaml > db-secret.yaml
kubeseal --format yaml < db-secret.yaml > db-sealed.yaml
rm db-secret.yaml
git add db-sealed.yaml && git commit -m "Add sealed DB secret"

Watch out

Back up the controller's key pair. Without it, a rebuilt cluster can not decrypt any sealed secret.

6.3

Use SOPS with age

SOPS encrypts only the values of a YAML file; keys stay readable for review.

age-keygen -o age.agekey
cat > .sops.yaml << 'EOF'
creation_rules:
  - path_regex: .*.secret.yaml
    encrypted_regex: ^(data|stringData)$
    age: age1qyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqs3290gq
EOF
sops --encrypt --in-place db.secret.yaml
sops db.secret.yaml
kubectl create secret generic sops-age -n flux-system --from-file=age.agekey

In the Flux Kustomization add decryption: { provider: sops, secretRef: { name: sops-age } }.

6.4

Use External Secrets Operator

The secret stays in Azure Key Vault (or Vault); Git only says which secret to fetch.

external-secret.yaml
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata: { name: db, namespace: shop }
spec:
  refreshInterval: 1h
  secretStoreRef: { name: azure-kv, kind: ClusterSecretStore }
  target: { name: db }
  data:
    - secretKey: password
      remoteRef: { key: shop-db-password }

Remember

With ESO, rotation happens in the store; the cluster picks up the new value at the next refresh — no Git commit needed.

All commands in this chapter