In this lab we will see how we can rollback an application in OpenShift quickly without switching to an older version of the source code in SCM.
In this Lab we will:
-
Use the same app we deployed in previous Web Hooks Lab. If you haven’t, please complete that Lab first.
-
Rollback the application using the OpenShift v3 command ``rollback''.
Step 1: Check application health status
-
Run:
$ oc get pods NAME READY STATUS RESTARTS AGE scm-web-hooks-1-build 0/1 Completed 0 1h scm-web-hooks-2-85bkw 1/1 Running 0 18m scm-web-hooks-2-build 0/1 Completed 0 19m
-
Inspecting the output of the above command we can see that we have a single replica of the previously deployed application running.
-
We can also see that previously two pods were used to build the application. OpenShift will create and docker deploy a pod per deployment. This tells us that we currently have two versions of the application.
-
You can also use:
$ oc get dc NAME REVISION DESIRED CURRENT TRIGGERED BY scm-web-hooks 2 1 1 config,image(scm-web-hooks:latest)
-
The latest and active version for the application is 2
-
If we display the application in the browser we see:
Step 2: Rollback the application
-
Using the previous command we ran to retrieve the deployment configuration, we will revert or rollback to version 1.
$ oc rollback scm-web-hooks --to-version=1 #3 rolled back to scm-web-hooks-1
-
If we re-run the command to list the build configurations, we now see:
$ oc get dc NAME REVISION DESIRED CURRENT TRIGGERED BY scm-web-hooks 3 1 1 config,image(scm-web-hooks:latest)
-
So OpenShift has rolled back the application to version 1 and created a new build configuration.
-
Reloading the application now displays: