Creating a Kubernetes Secret
Typically, you create a Kubernetes secret using the kubectl CLI command or by applying a YAML manifest. However, in line with GitOps best practices, all resources—including secrets—should be stored declaratively in Git. The challenge arises when storing Base64-encoded secrets in a repository. For instance, you can create a Kubernetes secret from a literal value by running:Overview of Available Solutions
There are several tools for managing Kubernetes secrets securely:- Bitnami Sealed Secrets
- HashiCorp Vault
- Kubernetes External Secrets
How Bitnami Sealed Secrets Work
The Sealed Secrets controller is deployed inside your Kubernetes cluster. It converts a plain Kubernetes secret into a sealed secret that is safe to store in any Git repository—even a public one. Only the controller can decrypt the sealed secret, ensuring that sensitive information stays protected. The controller can be installed in various ways, including Kustomize, Helm Charts, or directly from source. In our example, we deploy and manage the Sealed Secrets controller using ArgoCD via a Helm Chart.Deploying the Sealed Secrets controller via ArgoCD is optional; you can also opt to use Helm directly.
-cert flag. The certificate is typically stored in the Kubernetes secret created during the controller’s installation.
Deploying the Sealed Secrets Controller with ArgoCD
To deploy the Sealed Secrets controller with ArgoCD using a Helm Chart, run the following command:Encrypting the Secret with KubeSeal
After deploying the controller, install the KubeSeal CLI tool. The installation command downloads and installs KubeSeal into the/usr/local/bin directory:
-
The original Secret manifest (for reference):
-
The SealedSecret manifest that can be stored safely in Git: