- how to use kubectl to update a pod
To update a pod using kubectl
, you can use the kubectl set image
command. The basic syntax is as follows:
kubectl set image [pod-name] [container-name]=[new-image]
For example, if you want to update a pod named my-pod
and a container named my-container
to use a new image nginx:1.18
, you would run the following command:
kubectl set image my-pod my-container=nginx:1.18
You can also update multiple containers at once by specifying the container names separated by a comma.
kubectl set image my-pod my-container1=nginx:1.18,my-container2=nginx:1.19
This will update the pod in-place, which means that the pod will be deleted and recreated with the new image. This may cause a brief interruption