by kelseyhightower

kelseyhightower / vault-controller

Automate the creation of unique Vault tokens for Kubernetes Pods using init containers.

442 Stars 63 Forks Last release: Not found Apache License 2.0 34 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Vault Controller

The Vault Controller automates the creation of Vault tokens for Kubernetes Pods. This repo includes a set of hands-on tutorials and example programs you can use to try out the Vault Controller.


This is a prototype. Do not use this in production.

Use Case

  • Each Pod requires a dedicated Vault token tied to the Pod's life-cycle
  • Each Pod will use a dedicated Vault token to request secrets from a Vault server


How it Works

The following diagram demonstrates the flow Pods use to obtain a dedicated token when running in a Kubernetes cluster.

Vault Controller Flow

  1. An Init container requests a wrapped token from the Vault Controller
  2. The Vault Controller retrieves the Pod details from the Kubernetes API server
  3. If the Pod exists and contains the
    annotation a unique wrapped token is generated for the Pod.
  4. The Vault Controller "callsback" the Pod using the Pod IP obtained from the Kubernetes API.
  5. The Init container unwraps the token to obtain a dedicated Vault token.
  6. The dedicated token is written to a well-known location and the Init container exits.
  7. Another container in the Pod reads the token from the token file.
  8. Another container in the Pod renews the token to keep it from expiring.

More details can be found in the How it Works document.


The following tutorials will guide you through the deployment of the

and an example application to see how it all works.


Clone this repository:

git clone
cd vault-controller

Before you can complete the tutorials you'll need access to a Kubernetes clusters. Google Container Engine (GKE) or minikube should work.



Once you are done with the tutorials run the following command to clean up:

kubectl delete namespace vault-controller

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.