Bootstrap FreeKB - OpenShift - Deploy a new version of an application using the oc rollout command
OpenShift - Deploy a new version of an application using the oc rollout command

Updated:   |  OpenShift articles

A deployment is used to manage the pods that are created to run an application. The deployment ensures that the desired number of pod replicas are running and can handle updates to the application by rolling out new versions of the pods. The deployment creates and manages a replica set, which in turn manages the pods.

flowchart TB subgraph Project["OpenShift Project/Namespace"] Deployment[Deployment] Replica_Set[Replica Set] subgraph Pods["Pod Replicas"] Pod1[Pod 1
Container] Pod2[Pod 2
Container] Pod3[Pod 3
Container] end end Deployment -->|Creates/Manages| Replica_Set Replica_Set -->|Manages| Pod1 Replica_Set -->|Manages| Pod2 Replica_Set -->|Manages| Pod3 style Deployment fill:#90CAF9 style Replica_Set fill:#FFE082 style Pods fill:#FFCCBC

It is also noteworthy that a route provides a URL that can be used to access the application from outside the OpenShift cluster. For example, if the route is configured to use the hostname myapp.mydomain.com, then users can access the application by navigating to http://myapp.mydomain.com. The route will forward the request to the service, which will then forward the request to one of the pods that are running the application.

flowchart LR subgraph Project["OpenShift Project/Namespace"] subgraph Pods["Pod Replicas"] Pod1[Pod 1
Container] Pod2[Pod 2
Container] Pod3[Pod 3
Container] end SVC[Service] Route[Route] end USER[External User] --> Route --> SVC SVC --> Pod1 SVC --> Pod2 SVC --> Pod3 style SVC fill:#A5D6A7 style Pods fill:#FFCCBC style USER fill:#CE93D8

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

The oc get deploymentconfigs command can be used to list the deployments configs in the currently selected project. Notice in this example that TRIGGER BY has config and image.

~]$ oc get deploymentconfigs
NAME      REVISION   DESIRED   CURRENT   TRIGGERED BY
my-app    1          1         1         config,image(my-app:latest)

 

In the deployment config YAML, you should see triggers for config and image change. This means that when the deployment config YAML is changed or when the latest image is updated:

  1. The current replication controller will be set to 0 pods
  2. The current pods will be terminated
  3. A new replication controller will be created
  4. New pods will be deployed

Check out my article on triggers for more details on this.

spec:
  triggers:
  - type: ConfigChange
  - imageChangeParams:

 

The oc rollout latest command can be used to update the deployment to the latest image.

~]$ oc rollout latest deploymentconfig/my-app
deploymentconfig.apps.openshift.io/my-app rolled out

 

And then the oc rollout history command can be used to see that the latet image was rolled out. In this example, revision 1 is the original deployment and revision 2 is the roll out.

~]# oc rollout history deploymentconfig/my-app
deploymentconfig.apps.openshift.io/my-app
REVISION    STATUS      CAUSE
1           Complete    config change
2           Complete    manual change

 

If some problem occurs with the new deployment, the oc rollout undo command can be used to go back to a prior revision.

~]# oc rollout undo --to-revision 1 deploymentconfig/my-app
deploymentconfig.apps.openshift.io/my-app rolled back

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter bd262a in the box below so that we can be sure you are a human.