I wants to update the environment variables in a Kubernetes StatefulSet. I Updated the YAML file and executed $kubectl apply -f my-statefulset.yml
, but nothing changed. Then I tried $kubectl scale sts my-statefulset --replicas=0; kubectl scale sts my-statefulset --replicas=4
and it only recreated the last pod in the StatefulSet.
Dropping my entire StatefulSet and recreating it just to change an environment variable does not looks like a good idea. $kubectl patch
could work here, but I was not able to form the update json. I need a little help here on how to update environment variables in StatefulSet.
If your StatefulSet name is my-statefulset
, the below command should help you:
kubectl patch statefulset my-statefulset -p '{"spec":{"updateStrategy":{"type":"RollingUpdate"}}}'
More information you can find in Updating StatefulSets document.