Kuberetes Secret vs. Vault
General Recommendations
- Use kubernetes Secret if
- Secrets does not change often and are used exclusively within kubernetes
- Use secrets for things which are actually secret like API keys, credentials, etc
- Use config map for not-secret configuration data
- Use Vault with K8S Authentication method if:
- secrets need to be used outside of kubernetes containers
Solution comparison chart
Kubernetes Secret Management
Kubernetes secret management
- K8S Secret
- H Vault integration using open source projects
- H Vault integration using K8S Auth Method
Secret management solutions
- Ways to manage and inject secrets to containers:
- Storing secrets in a secret object file is safer and more flexible than putting in a pod definition.
Kubernetes Secrets flow
- Admin creates a secret via kubectl, that makes create secret request to the API Server
- Secrets are written to database
- Secrets are provisioned to the slave node that’s running the container
- Secrets are mounted as volume or injected to the environment variable of the target container
Kubernetes secrets and some gotchas
- Secrets can be provisioned to a container or a namespace, containers under the namespace have access to the secrets under the same NS.
- Secrets are written to a tempFS which are deleted on pod terminition.
- Secrets are size limited to 1Mb
- Make sure all secrets are created before referencing in containers, otherwise the Pod will hang because container has trouble mounting secret volume
- Only possible to mount one secret per directory. Mounting a secret will mask the content of the directory.
Kubernetes Secrets summary
- Secret auditing with Kubernetes Audit
- Revocation and rotation can be done by deleting and recreating secrets
- Easy to use and tightly integrated to kubernetes
Comments
Post a Comment