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
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:6443Login 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 wideNAME READY ... CONTAINERS IMAGES ... app1 1/1 ...php-sslregistry...:8443/redhattraining/php-ssl:latest...In the
Deploymentobject, change the image toregistry.ocp4.example.com:8443/redhattraining/php-ssl:1-222.[student@workstation ~]$
oc set image deployment/app1 \php-ssl=registry.ocp4.example.com:8443/redhattraining/php-ssl:1-222deployment.apps/app1 image updatedVerify your work.
[student@workstation ~]$
oc get deployment/app1 -o wideNAME 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 wideNAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS ... app2 1/1 1 1 21mphp-ssl...Add the image trigger to the
Deploymentobject.[student@workstation ~]$
oc set triggers deployment/app2 \--from-image php-ssl:1 --containers php-ssldeployment.apps/app2 triggers updatedVerify your work.
[student@workstation ~]$
oc set triggers deployment/app2NAME TYPE VALUE AUTO deployments/app2 config true deployments/app2 imagephp-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-234imagestreamtag.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:1Tag 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/app2Name: app2 Namespace: updates-review ...output omitted... Events: Type ... Age Message ---- ---- ------- Normal ... 33m ... Scaled up replica set app2-7dd589f6d5 to 1Normal ... 3m30s ... Scaled up replica set app2-7bf5b7787 to 1Normal ... 3m28s ... Scaled down replica set app2-7dd589f6d5 to 0 from 1