Table of Contents
| Step | Description | Reference Command |
|---|---|---|
| 1. Background | Plaintext Secret in Git | – |
| 2. Automatic Reconciliation | FluxCD constantly applies Git manifests | kubectl -n database get po,secret |
| 3. Suspend Reconciliation | Pause FluxCD Kustomization | flux suspend kustomization … |
| 4. Trigger Pod Failure | Restart Pod to observe missing Secret | kubectl rollout restart … |
| 5. Encrypt with kubeseal | Generate a SealedSecret | kubeseal --cert … |
| 6. Replace Plaintext | Commit encrypted manifest to Git | git add sealed-secret-mysql.yaml |
| 7. Resume Reconciliation | Apply updated Git source and resume FluxCD | flux resume kustomization … |
| 8. Verify Decryption | Confirm the decrypted Secret in cluster | kubectl get secret … |
1. Background: Plaintext Secret in Git
We have a FluxCDKustomization that applies manifests from a Git repository:
./database/secret-mysql.yaml, the MySQL password is stored in plaintext:
Storing passwords or tokens in plaintext within Git exposes them to unauthorized access. Always encrypt sensitive data before committing.
2. Demonstrate Automatic Reconciliation
Verify the Secret and Pod exist:3. Suspend Reconciliation
Pause theKustomization so FluxCD stops reconciling this directory:
4. Trigger Pod Failure
Force a deployment restart to spawn a new Pod, which will fail due to the missing Secret:CreateContainerConfigError:
5. Encrypt the Secret with kubeseal
Ensure you have:- The
kubesealCLI installed. - The Sealed Secrets public key (
sealed-secrets.pub).
SealedSecret resource:
Only the Secret’s values are encrypted. The keys (
password) stay in cleartext for mapping.6. Replace the Plaintext Secret
Backup the original manifest and commit the sealed version:7. Resume Reconciliation
Sync your Git source and resume the Kustomization:SealedSecret, and the Bitnami controller decrypts it into a normal Kubernetes Secret in database.
8. Verify the Decrypted Secret
Check that the Secret has been created:9. Conclusion
You have successfully:- Suspended FluxCD reconciliation.
- Deleted a plaintext Secret and saw a Pod failure.
- Used
kubesealto create an encryptedSealedSecret. - Committed the
SealedSecretto your Git repo. - Resumed FluxCD reconciliation and verified automatic decryption.
Links and References
- Bitnami Sealed Secrets GitHub
- FluxCD Kustomization Documentation
- Kustomize Tooling
- Kubernetes Secrets