By Hemanta Sundaray on 2022-07-15
In Docker Hub, I have two versions of a container image: sundaray/node-server:v1 & sundaray/node-server:v2.
Currently, I have a running container on a Kubernetes cluster using the image tagged with v1.
Now, if I want the running container to use the image tagged with v2, I can use the kubectl set image command (without editing the YAML of the Deployment object).
kubectl set image deployment/<deployment_name> <container_name>/<image_name>:<tag_name>
When I execute the command above, the image used in the container is changed to sundaray/node-server:v2 (from :v1).
Now if I check the YAML definition of the pod, I can see that the container is using the new image.