How do you update an existing Deployment to use a new image tag?

Prepare for the Red Hat Openshift Developer EX288 Exam. Study with comprehensive quizzes and flashcards. Each question includes hints and explanations to enhance your understanding. Ace your exam with confidence!

Multiple Choice

How do you update an existing Deployment to use a new image tag?

Explanation:
Updating a Deployment to use a new image tag is done by performing a rolling update on the Deployment’s Pod template. This means changing the image reference for the container in the Deployment so that Kubernetes/OpenShift gradually replaces old pods with new ones running the updated image, without taking the app offline. You can do this in a few straightforward ways. One common method is using the OpenShift CLI: oc set image deployment/<name> <container>=<image:tag>. This updates the image for that container and triggers a new rollout that replaces pods with the new version. Another valid approach is to edit the Deployment YAML (specifically spec.template.spec.containers[].image) to the new image:tag and apply the changes; this also starts a rolling update. You can also configure an ImageChange trigger so that an update to the image stream automatically triggers a deployment, enabling automatic rollouts in CI/CD workflows. Deleting the deployment and recreating it is not desirable because it disrupts the running application and bypasses the controlled rolling update process. Rebuilding the entire cluster is unnecessary for updating a single deployment’s image.

Updating a Deployment to use a new image tag is done by performing a rolling update on the Deployment’s Pod template. This means changing the image reference for the container in the Deployment so that Kubernetes/OpenShift gradually replaces old pods with new ones running the updated image, without taking the app offline.

You can do this in a few straightforward ways. One common method is using the OpenShift CLI: oc set image deployment/ =image:tag. This updates the image for that container and triggers a new rollout that replaces pods with the new version. Another valid approach is to edit the Deployment YAML (specifically spec.template.spec.containers[].image) to the new image:tag and apply the changes; this also starts a rolling update. You can also configure an ImageChange trigger so that an update to the image stream automatically triggers a deployment, enabling automatic rollouts in CI/CD workflows.

Deleting the deployment and recreating it is not desirable because it disrupts the running application and bypasses the controlled rolling update process. Rebuilding the entire cluster is unnecessary for updating a single deployment’s image.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy