Kuberetes Secret vs. Vault


General Recommendations

  1. 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
  2. Use Vault with K8S Authentication method if: 
    • secrets need to be used outside of kubernetes containers


Solution comparison chart


K8S Secret
Vault with K8S
Vault with K8S Auth method
Do we need to provision secret zero to our app/cluster in order to bootstrap trust?
Yes, database encryption key and tls certs need to be provisioned to setup the K8S cluster via other means
K8S Vault Controller need to be authenticated with Vault. 
Authentication need to be setup between Vault and K8S.
Is it cloud provider agnostic? 
Yes, but limited to app running in containers managed by K8S
Yes, but relies on Hashicorp Vault
Relies on Hashicorp Vault
Amount of effort to integrate into application
Little, K8S cluster need to be secured
Moderate, require Vault and Controllers
Little
Recommended scenarios
Good for containers orchestrated by Kubernetes. Secrets are not used anywhere else. Require other means to provision database encryption key
Good for secrets required to be shared across platforms. Integration with K8S is possible via open source projects.
Best for secrets required to be shared across platforms. Simple integration makes this the best way to manage secrets on K8S



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


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

Popular posts from this blog

AWS Auto AMI(Instance) backup across all region

Digital-ocean-auto volume backup

How to Set Up an Nginx Ingress with Cert-Manager on DigitalOcean Kubernetes