Saturday, July 14, 2018

Rolling Upgrade Kubernetes 1.6 Statefulset

statefulsetgrade

Upgrade StatefulSet Image (k8s 1.6)

For K8s 1.6, Rollout is still not support Statefulset. But we can use patch and manually restart the PODS to upgrade images.

First of all, we just use the following command and fill the target image in "image".

kubectl patch statefulset mariadbcluster -p'{"spec":{"template":{"spec":{"containers":[{"name":"mariadbcluster","image":"192.168.51.130:5000/mariadbcluster:vtest2"}]}}}}'

You will see the statefulset's image has been replaced to new images.

kubectl describe statefulset mariadbcluster
.
.
.
  Containers:
   mariadbcluster:
    Image:  192.168.51.130:5000/mariadbcluster:vtest2

Sequentially, restart the POD. Here is just an example for delete of one the POD.

kubectl delete po mariadbcluster-2

After the POD restart successfully, to check the pod's info, we will get the new image. You might login to the POD to check the code is right. Of course, it's right. I did it.

kubectl describe po mariadbcluster-2
 .
 .
 .
 
 Image:     192.168.51.130:5000/mariadbcluster:vtest2

You can compare the upgraded POD to Non-Upgraded POD.

root@kubecontext:~/k8sdeployex/statefulupgrade# kubectl describe po mariadbcluster-1
.
.

Image:      192.168.51.130:5000/mariadbcluster:vtest3

Great!!!.

No comments:

Post a Comment