How to restart Kubernetes pod when a secret is updated in Hashicorp Vault? How to restart Kubernetes pod when a secret is updated in Hashicorp Vault? kubernetes kubernetes

How to restart Kubernetes pod when a secret is updated in Hashicorp Vault?


Use reloader https://github.com/stakater/Reloader. We found it quite useful in our cluster. It does a rolling update hence you can change config with zero downtime too. Also if you made some errors in configmap you can easily do a rollback.


A couple ideas, depending on how much effort you want to put into it:

  1. Just restart the pod every so often. A hacky way to do this is with a liveness probe, like this answer. Drawback is you can't use the liveness probe as a real health check without additional scripting.

  2. Create an operator that polls Vault for changes and instructs Kubernetes to restart the pod when a change is detected. Not sure if Vault has an events API that you could use for that.


https://www.vaultproject.io/docs/agent/template#renewals-and-updating-secrets

If a secret or token isn't renewable or leased, Vault Agent will fetch the secret every 5 minutes. This is not configurable. Non-renewable secrets include (but not limited to) KV Version 2.