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.
執筆者紹介
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.
チャンネル別に見る
自動化
テクノロジー、チームおよび環境に関する IT 自動化の最新情報
AI (人工知能)
お客様が AI ワークロードをどこでも自由に実行することを可能にするプラットフォームについてのアップデート
オープン・ハイブリッドクラウド
ハイブリッドクラウドで柔軟に未来を築く方法をご確認ください。
セキュリティ
環境やテクノロジー全体に及ぶリスクを軽減する方法に関する最新情報
エッジコンピューティング
エッジでの運用を単純化するプラットフォームのアップデート
インフラストラクチャ
世界有数のエンタープライズ向け Linux プラットフォームの最新情報
アプリケーション
アプリケーションの最も困難な課題に対する Red Hat ソリューションの詳細
仮想化
オンプレミスまたは複数クラウドでのワークロードに対応するエンタープライズ仮想化の将来についてご覧ください