Generate Kubernetes Secret manifests safely
A Secret holds small amounts of sensitive data — passwords, tokens, TLS certificates, registry credentials — and makes it available to pods without baking it into images. This builder assembles a valid v1 Secret manifest, base64-encoding your values for the data field or leaving them plaintext under stringData.
How it works
The Kubernetes data field stores every value base64-encoded. The builder encodes your input using a UTF-8-safe routine so multi-byte characters survive correctly, which a naive btoa call would corrupt. If you prefer to author in plaintext, switch to stringData and the API server performs the base64 encoding when you kubectl apply.
The Secret type field tells Kubernetes what shape to expect. Opaque is the generic catch-all; typed Secrets such as kubernetes.io/tls validate that the required keys (tls.crt, tls.key) are present.
Tips and notes
- base64 is encoding, not encryption — anyone who can read the Secret can decode it instantly. Enable encryption at rest on etcd for real protection.
- For GitOps workflows, use Sealed Secrets (encrypts the whole Secret so it is safe to commit) or the External Secrets Operator (syncs from Vault, AWS Secrets Manager, or GCP Secret Manager).
- Restrict access with RBAC — grant
get/liston Secrets only to the workloads that need them. - Rotate credentials regularly; updating a Secret does not automatically restart pods consuming it.