Lab: Manage Application Updates
Update two live applications to their latest releases as identified by non-floating tags.
Outcomes
You should be able to configure Deployment objects with images and triggers, and configure image stream tags and aliases.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that all resources are available for this exercise. It also creates the updates-review project and deploys two applications, app1 and app2, in that project.
The command creates the /home/student/DO180/labs/updates-review/resources.txt file. The resources.txt file contains the name of the images that you use during the exercise. You can use the file to copy and paste these image names.
[student@workstation ~]$ lab start updates-review
Procedure 7.5. Instructions
The API URL of your OpenShift cluster is https://api.ocp4.example.com:6443, and the oc command is already installed on your workstation machine.
Log in to the OpenShift cluster as the developer user with the developer password. Use the updates-review project for your work.
Your team created the
app1deployment in theupdates-reviewproject from theregistry.ocp4.example.com:8443/redhattraining/php-ssl:latestcontainer image. Recently, a developer in your organization pushed a new version of the image and then reassigned thelatesttag to that version.Reconfigure the
app1deployment to use the1-222static tag instead of thelatestfloating tag, to prevent accidental redeployment of your application with untested image versions that your developers can publish at any time.Log in to the OpenShift cluster.
[student@workstation ~]$ oc login -u developer -p developer \ https://api.ocp4.example.com:6443 Login successful. ...output omitted...Set the
updates-reviewproject as the active project.[student@workstation ~]$ oc project updates-review ...output omitted...Verify that the
app1deployment uses thelatesttag. Retrieve the container name.[student@workstation ~]$ oc get deployment/app1 -o wide NAME READY ... CONTAINERS IMAGES ... app1 1/1 ... php-ssl registry...:8443/redhattraining/php-ssl:latest ...In the
Deploymentobject, change the image toregistry.ocp4.example.com:8443/redhattraining/php-ssl:1-222. Ignore the warning message.[student@workstation ~]$ oc set image deployment/app1 \ php-ssl=registry.ocp4.example.com:8443/redhattraining/php-ssl:1-222 Warning: would violate PodSecurity "restricted:v1.24": ...output omitted... deployment.apps/app1 image updatedVerify your work.
[student@workstation ~]$ oc get deployment/app1 -o wide NAME READY ... CONTAINERS IMAGES ... app1 1/1 ... php-ssl registry...:8443/redhattraining/php-ssl:1-222 ...
The
app2deployment is using thephp-ssl:1image stream tag, which is an alias for thephp-ssl:1-222image stream tag.Enable image triggering for the
app2deployment, so that whenever thephp-ssl:1image stream tag changes, OpenShift rolls out the application. You test your configuration in a later step, when you reassign thephp-ssl:1alias to a new image stream tag.Retrieve the container name from the
Deploymentobject.[student@workstation ~]$ oc get deployment/app2 -o wide NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS ... app2 1/1 1 1 21m php-ssl ...Add the image trigger to the
Deploymentobject. Ignore the warning message.[student@workstation ~]$ oc set triggers deployment/app2 \ --from-image php-ssl:1 --containers php-ssl Warning: would violate PodSecurity "restricted:v1.24": ...output omitted... deployment.apps/app2 triggers updatedVerify your work.
[student@workstation ~]$ oc set triggers deployment/app2 NAME TYPE VALUE AUTO deployments/app2 config true deployments/app2 image php-ssl:1 (php-ssl) true
A new image version,
registry.ocp4.example.com:8443/redhattraining/php-ssl:1-234, is available in the container registry. Your QA team tested and approved that version. It is ready for production.Create the
php-ssl:1-234image stream tag that points to the new image. Move thephp-ssl:1image stream tag alias to the newphp-ssl:1-234image stream tag. Verify that theapp2application redeploys.Create the
php-ssl:1-234image stream tag.[student@workstation ~]$ oc create istag php-ssl:1-234 \ --from-image registry.ocp4.example.com:8443/redhattraining/php-ssl:1-234 imagestreamtag.image.openshift.io/php-ssl:1-234 createdMove the
php-ssl:1alias to the newphp-ssl:1-234image stream tag.[student@workstation ~]$ oc tag --alias php-ssl:1-234 php-ssl:1 Tag php-ssl:1 set up to track php-ssl:1-234.Verify that the
app2application rolls out. The names of the replica sets on your system probably differ.[student@workstation ~]$ oc describe deployment/app2 Name: app2 Namespace: updates-review ...output omitted... Events: Type ... Age Message ---- ---- ------- Normal ... 33m ... Scaled up replica set app2-7dd589f6d5 to 1 Normal ... 3m30s ... Scaled up replica set app2-7bf5b7787 to 1 Normal ... 3m28s ... Scaled down replica set app2-7dd589f6d5 to 0 from 1
Evaluation
As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.
[student@workstation ~]$ lab grade updates-review
Finish
As the student user on the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.
[student@workstation ~]$ lab finish updates-review
