1. Declarative Secret Storage
According to GitOps principles, all Kubernetes resources—including secrets—should live as code in your Git repository.Creating a Standard Secret
Base64 encoding is not secure encryption. Never commit raw or Base64‐encoded secrets to Git.
2. Secret Management Solutions
Compare popular tools for encrypting Kubernetes secrets in GitOps repositories:| Tool | Description | Repository |
|---|---|---|
| Bitnami Sealed Secrets | Seal/unseal secrets with a controller and CLI | https://github.com/bitnami-labs/sealed-secrets |
| HashiCorp Vault | Centralized secrets vault with dynamic creds | https://www.vaultproject.io/ |
| Mozilla SOPS | Encrypt YAML/JSON files | https://github.com/mozilla/sops |
| GoDaddy Kubernetes External Secrets | Fetch secrets from external providers | https://github.com/godaddy/kubernetes-external-secrets |
3. What Are Bitnami Sealed Secrets?
Bitnami Sealed Secrets provides:- A Kubernetes controller that decrypts sealed secrets inside the cluster.
- A kubeseal CLI to encrypt Kubernetes Secret manifests to SealedSecret manifests.
- A safe-to-commit SealedSecret format (even on public repos) that only your controller can decrypt.
4. Installing the Sealed Secrets Controller with Flux
Deploy the controller as a HelmRelease in Flux:kube-system namespace.
5. Encrypting a Secret with kubeseal
Follow these steps to seal your plain Secret:-
Generate the plain Secret manifest (if not already done):
-
Install the
kubesealclient: -
Fetch the public certificate from the controller:
-
Seal the Secret:
The
--scope cluster-wide flag allows decryption in any namespace. Omit or change the scope for namespace-restricted secrets.6. Example Manifests
6.1 Original Kubernetes Secret
6.2 Resulting SealedSecret
7. Applying the SealedSecret with Flux
- Commit
mysql-password_sealedsecret.yamlto your Git repo. - Flux syncs and applies the SealedSecret resource.
- The Sealed Secrets controller in the cluster decrypts it and creates a standard Kubernetes Secret.
- Your workloads can reference the decrypted Secret just like any other.
8. Summary
By integrating Bitnami Sealed Secrets with Flux, you get:- Encrypted Secret manifests stored safely in Git.
- Automated HelmRelease deployment of the Sealed Secrets controller.
- CLI-driven encryption (
kubeseal) and in-cluster decryption. - A fully GitOps-friendly secret management workflow for Kubernetes.