I am running a HashiCorp Vault stateless set in K8s with 3 pods on three nodes.
After deployment I manually unseal Vault. Vault then stays unsealed all the time.
The problem is when one of the nodes is restarted, the Vault pod restarts in unsealed mode. Is there any way to automatically unseal the Vault node by server-server-communication with one of the already unsealed pods?
I do not want to have to unseal the Vault pods manually when my Kubernetes environment gets updated and all nodes get restarted (rolling update - one by one).
I also do not want to store the unseal keys in a K8s secret or even a file as this makes encryption of my secrets useless.
This is my yaml:
apiVersion: v1
kind: Service
metadata:
name: vault
spec:
clusterIP: None
ports:
- name: http
port: 8200
- name: server
port: 8201
selector:
xyz.service: vault
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: vault
labels:
xyz.service: vault
spec:
serviceName: "vault"
selector:
matchLabels:
xyz.service: vault
replicas: 3
template:
metadata:
labels:
xyz.service: vault
spec:
imagePullSecrets:
- name: reg-dhc-xyzoms-pull-secret
securityContext:
runAsUser: 100
fsGroup: 1000
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: xyz.service
operator: In
values:
- vault
topologyKey: kubernetes.io/hostname
containers:
- name: vault
image: vault:0.11.0
resources:
requests:
memory: "100Mi"
env:
- name: SKIP_SETCAP
value: dontcare
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: "status.podIP"
- name: "VAULT_CLUSTER_ADDR"
value: "https://$(POD_IP):8201"
ports:
- name: http
containerPort: 8200
protocol: "TCP"
- name: server
containerPort: 8201
protocol: "TCP"