Learn to use Bitnami Sealed Secrets for secure secret management in GitOps with Kubernetes, covering installation, encryption, and deployment processes.
In this guide, you’ll learn how to use Bitnami Sealed Secrets to securely commit secrets to any public or private Git repository. We will cover installing the Sealed Secrets controller via Helm and using the kubeseal CLI to encrypt Kubernetes secrets before pushing them to Git.Let’s begin by exploring the available documentation. The Argo CD documentation offers several secret management options. Although Argo CD does not mandate a specific method, this article focuses on Bitnami Sealed Secrets (with a brief mention of the Argo CD Vault plugin, which integrates with HashiCorp Vault).
First, add the Helm repository URL for Sealed Secrets to Argo CD. While you might deploy the Helm chart with the Helm CLI, this guide uses Argo CD for GitOps management.Run the following command to add the Helm repository:
Next, create a new Argo CD application to manage the Helm chart. Name the application (for example, “Sealed Secrets”), choose the default project, and ensure the installation targets the kube-system namespace. For demonstration purposes, we will use version 2.2.0 of the Helm chart while keeping the default chart values.
After configuring the new application, proceed to create it.
When you create the application, you will notice several resources being scheduled for creation, such as services, service accounts, CRDs, pods, cluster roles, role bindings, and more.
To verify the created resources in your Kubernetes cluster, run:
Copy
kubectl -n kube-system get all | grep -i sealed
You should see a pod, service, deployment, and replicaset, as well as one Sealed Secret key:
Copy
kubectl -n kube-system get all | grep -i sealedkubectl -n kube-system get secrets | grep -i sealed
The CLI communicates with the Sealed Secrets controller (running in kube-system) to perform the encryption. If needed, download the binary manually. For example, to download version 0.18.0:
This sequence encrypts your secret, preparing it for safe storage in Git.For a more involved example with multiple key-value pairs, create a secret like so:
The generated YAML manifest will base64 encode the values, which alone is not secure. You must encrypt it with kubeseal.Before encrypting the YAML file, retrieve the TLS certificate from the Sealed Secrets controller:
Once you have the SealedSecret YAML file (e.g., aws-crds-sealed.yaml), add it to your GitOps repository. When Argo CD synchronizes the repository, the Sealed Secrets controller in your cluster automatically decrypts the secret and creates a standard Kubernetes Secret in the target namespace.Here’s an example of what a decrypted secret might look like:
When the application starts, it will access secret data at the specified mount path (for example, /app/crds/username, /app/crds/password, /app/crds/apikey).
Ensure that the volume mounts and volumes sections are uncommented and correctly configured. In one demonstration, the application logged warnings about missing files because the volume mount was commented out.
Create a new Argo CD application for your GitOps repository, which contains both your SealedSecret and deployment manifests. For example, if your repository holds the encrypted secret (e.g., aws-crds-sealed.yaml or renamed as required), set the target namespace appropriately (e.g., default). When you synchronize the application in Argo CD, the Sealed Secrets controller unseals the secret, and the application pod begins using the secret data.
If you encounter an error such as “cannot get sealed secret service: services ‘sealed-secrets-controller’ not found,” verify that the Sealed Secrets controller is running in the kube-system namespace. In some cases, issues auto-resolve after a brief period.
Events shown on the secret management dashboard confirm that the sealed secret was eventually unsealed and the secret resource created:
Finally, access the service (for example, a NodePort service) to verify that your application picks up the unsealed secret values. In one demonstration, the application output revealed the plaintext secret as intended when accessed via a browser or using curl on the exposed port.
This completes our walkthrough on securing secrets with Bitnami Sealed Secrets in a GitOps workflow. Happy securing!