Prerequisites
- A Git repository with your application code checked out.
- Administrator-generated PGP keypair (public key committed in
infrastructure/SOPS/). - FluxCD installed in your cluster.
gpg,git,wget, andkubectlavailable on your machine.
Table of Contents
- Prepare the Repository
- Import the Public PGP Key
- Install SOPS
- Encrypt the Secret with SOPS
- Commit and Push
- Configure FluxCD Decryption
- Verify Decrypted Secret in Cluster
1. Prepare the Repository
Switch to your infrastructure branch and restore the plaintext secret for re-encryption.Always back up existing sealed or encrypted secrets before modifying them.
Verify the plaintext
Secret at database/secret-mysql.yaml:
2. Import the Public PGP Key
On a fresh developer machine, confirm you have no existing public keys:CE284BB236654E42A):
You will use the PGP fingerprint with the
sops CLI to encrypt your secret.3. Install SOPS
Install the SOPS binary if it’s not already present:4. Encrypt the Secret with SOPS
Navigate to the directory containing your plaintext secret:data and stringData sections in place:
secret-mysql.yaml will include an sops: block:
Encryption Backends Supported by SOPS
5. Commit and Push
Add the encrypted secret to your Git repository and push:6. Configure FluxCD Decryption
FluxCD needs the private key stored in a KubernetesSecret (e.g., sops-gpg) and decryption enabled in the Kustomization manifest.
Edit infrastructure/flux/kustomization-database.yaml: