Skip to main content

How to check deployment health on Red Hat OpenShift

Find out how to check pod status for your OpenShift deployments.

Image by StockSnap from Pixabay

When deploying applications to Red Hat OpenShift, it's useful to check the status and health of the components. First, I'll show you how deployments work, and then you can check out some health reports.

How OpenShift APIs are deployed

Red Hat OpenShift applications can be created using a container image hosted on a remote registry, a YAML file that specifies the resources to create, a builder image using the source code from your Git repository, a Dockerfile, and more.

[ You might also like: How I constructed an interactive OpenShift lecture for Red Hat Academy. ]

Depending on the method selected, a Deployment or DeploymentConfig API object may be used. OpenShift supports both Deployment objects and DeploymentConfig objects; however, Deployment objects are recommended unless you need a specific feature provided by DeploymentConfig objects.

In OpenShift, when creating applications from a YAML file, Deployment objects are preferred. When building applications from a Dockerfile or from source, a DeploymentConfig object will be created automatically by the oc new-app command.

When troubleshooting DeploymentConfig or Deployment APIs, focus on the states of the replicas and pods that are created. A DeploymentConfig creates a ReplicationController that manages pod lifecycles. In the same way, Deployment creates replicas that manage the pods.

MySQL deployment example

This example creates a MySQL database from an image hosted at registry.access.redhat.com:

oc new-app --docker-image=registry.access.redhat.com/rhscl/mysql-57-rhel7:latest --name=mydb -e MYSQL_USER=user1 -e MYSQL_PASSWORD=mypa55 -e MYSQL_DATABASE=testdb -e MYSQL_ROOT_PASSWORD=r00tpa55

[sysadmin@server ~]$ oc describe dc mydb
Name: mydb
Namespace: DEV
Created: 130 minutes ago
Labels: app=dev
...output omitted...
Deployment #1 (latest):
Name: mydb-1
Created: 15 minutes ago
Status: Complete
Replicas: 1 current / 1 desired
Selector: app=mydb,deployment=mydb-1,deploymentconfig=mydb
Labels: app=mydb,openshift.io/deployment-config.name=mydb
Pods Status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed
...output omitted...

From this, you can deduce the following:

  • Status: Complete - The DeploymentConfig completed successfully.
  • Replicas: 1 current / 1 desired - You wanted one pod to be created (desired) and one has been created successfully (current).
  • Pods status: 1 Running / 0 Waiting / 0 Succeeded / 0 Failed - There is one pod running with none failing, and that’s very important. Any failed pod needs to be investigated and fixed, as that will mean an unhealthy deployment.

PHP application deployment

This second example deploys a PHP application, and this is a description of the DeploymentConfig:

[sysadmin@server]$ oc describe dc/php-helloworld
Name: php-helloworld
Namespace: web
Created: 12 minutes ago
Labels: app=php-helloworld
Annotations: openshift.io/generated-by=OpenShiftNewApp
Latest Version: 1
Selector: app=php-helloworld,deploymentconfig=php-helloworld
Replicas: 1
Triggers: Config, Image(php-helloworld@latest, auto=true)
Strategy: Rolling
Template:
Labels: app=php-helloworld
deploymentconfig=php-helloworld
...output omitted...
Containers:
php-helloworld:
Image: image-registry.openshift-image-registry.svc:5000/s2i/phphelloworld@
sha256:6d27...b983
Ports: 8080/TCP, 8443/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Deployment #1 (latest):
Name: php-helloworld-1
Created: 5 minutes ago
Status: Complete
Replicas: 3 current / 5 desired
Selector: app=php-helloworld,deployment=php-helloworld-1,deploymentconfig=phphelloworld
Labels: app=php-helloworld,openshift.io/deployment-config.name=php-helloworld
Pods Status: 3 Running / 0 Waiting / 0 Succeeded / 2 Failed
...output omitted...

As you can see, there are two failed pods. This indicates the deployment is not healthy and needs to be investigated. Administrators can view logs from the individual pods and apply the appropriate fix.

[ Learn the basics of using Kubernetes in this free cheat sheet. ] 

Wrap up

When troubleshooting deployments, it’s always important to look out for the pod's status, the number of replicas desired, and how many are currently running. Such information can make troubleshooting easier and more efficient.

Topics:   Linux   Linux administration   OpenShift  
Author’s photo

Evans Amoany

I work as Unix/Linux Administrator with a passion for high availability systems and clusters. I am a student of performance and optimization of systems and DevOps. I have passion for anything IT related and most importantly automation, high availability, and security. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.