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.
Sobre el autor
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.
Más como éste
Behind the scenes of RHEL 10, part 3
Alliander modernises its electricity grid with Red Hat for long-term reliability in balance with rapid innovation
OS Wars_part 1 | Command Line Heroes
OS Wars_part 2: Rise of Linux | Command Line Heroes
Navegar por canal
Automatización
Las últimas novedades en la automatización de la TI para los equipos, la tecnología y los entornos
Inteligencia artificial
Descubra las actualizaciones en las plataformas que permiten a los clientes ejecutar cargas de trabajo de inteligecia artificial en cualquier lugar
Nube híbrida abierta
Vea como construimos un futuro flexible con la nube híbrida
Seguridad
Vea las últimas novedades sobre cómo reducimos los riesgos en entornos y tecnologías
Edge computing
Conozca las actualizaciones en las plataformas que simplifican las operaciones en el edge
Infraestructura
Vea las últimas novedades sobre la plataforma Linux empresarial líder en el mundo
Aplicaciones
Conozca nuestras soluciones para abordar los desafíos más complejos de las aplicaciones
Virtualización
El futuro de la virtualización empresarial para tus cargas de trabajo locales o en la nube