Getting accurate status of openshift pod deployment

9/19/2019

I have deployment stage in Jenkins which executes "oc patch" and "oc rollout" commands. These commands replaces docker image name in DeploymentConfig and rollout the changes in openshift. As you can imagine, this is asynchronous call. It means in Jenkins I am not able to verify if newly deployed pod is running or failing. Jenkins just executes oc commands and proceeds to next stage execution. My requirement is I want to get the actual status of pod back in Jenkins to mark pipeline success/failed.

I could not find any oc or kubectl command which provides me exact status of deployment using synchronous call. As workaround I wrote shell script which checks the status of pod (using grep)for certain amount of time post "oc rollout" and send exit status back to Jenkins shell. I feel this is not correct method to do the deployment validation as my pipeline execution time is increased.

Do we have standard utility in openshift/kubernetes which can provide me exact status of pod post deployment on which I can rely and using which I can mark my deployment pipeline success/fail in Jenkins.

Please note, I am opening shell session in pipeline and executing oc cli commands on agent which has oc cli installed. This agent is not part of openshift cluster and Jenkins is sitting outside openshift cluster.

-- nil13
jenkins
kubernetes
openshift

1 Answer

9/19/2019

You have to use oc rollout status

Synopsis

oc rollout status

Description

Watch the status of the latest rollout, until it's done.

-- prometherion
Source: StackOverflow