Monitoring your containers in a pod is key to knowing the utilization and as a measure of auto scaling – HPA / VPA. These metrics will help you set Resource Quotas and Limit Ranges in an OpenShift / OKD / OpenShift cluster. In this guide, I will show you how you can check for Pod / Container metrics from CLI.

OpenShift comes with metrics server installed. For Kubernetes, use our guide below.

How To Deploy Metrics Server to Kubernetes Cluster

As a cluster administrator, you can configure and tune your cluster metrics to the desired state. If metrics are configured correctly, you can use the command below to show for a pod.

$ kubectl describe PodMetrics <pod-name>

In my project, I have a number of pods as shown below.

$ oc get pods
NAME                                           READY   STATUS    RESTARTS   AGE
harbor-harbor-chartmuseum-5456c9d756-97pdd     1/1     Running   0          38h
harbor-harbor-clair-654dcfd8bf-kgxk4           2/2     Running   0          38h
harbor-harbor-core-76d64c78b6-kv24c            1/1     Running   1          38h
harbor-harbor-database-0                       1/1     Running   0          38h
harbor-harbor-jobservice-849f5cb79-qnw6v       1/1     Running   0          38h
harbor-harbor-notary-server-54cbdcffb7-98qjb   1/1     Running   1          38h
harbor-harbor-notary-signer-5dd4d88c8d-mnq44   1/1     Running   2          38h
harbor-harbor-portal-5cbc6d5897-gnfnz          1/1     Running   0          38h
harbor-harbor-redis-0                          1/1     Running   0          38h
harbor-harbor-registry-5b5767dcb9-btlk7        2/2     Running   0          38h
jaeger-operator-7dbfd8c587-9l9hr               1/1     Running   0          6d15h

We can then check the metrics of harbor-harbor-database-0 pod using the command:

$ oc describe PodMetrics harbor-harbor-database-0

If metrics are configured, the output appears similar to the following, with Cpu and Memory displayed under Usage.

Name:         harbor-harbor-database-0
Namespace:    harbor
Labels:       <none>
Annotations:  <none>
API Version:
  Name:  remove-lost-found
    Memory:  0
  Name:      database
    Cpu:     6m
    Memory:  344348Ki
  Name:      change-permission-of-directory
    Memory:  0
Kind:        PodMetrics
  Creation Timestamp:  2020-04-09T10:32:04Z
  Self Link:           /apis/
Timestamp:             2020-04-09T10:32:04Z
Window:                5m0s
Events:                <none>

For Kubernetes, use the kubectl command and specify namespace at the end using the -n option.

$ kubectl describe PodMetrics kuard
Name:         kuard
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:
  Name:  kuard
    Cpu:     101379n
    Memory:  8960Ki
Kind:        PodMetrics
  Creation Timestamp:  2020-04-09T10:40:24Z
  Self Link:           /apis/
Timestamp:             2020-04-09T10:39:34Z
Window:                30s
Events:                <none>

OpenShift Courses:

Practical OpenShift for Developers – New Course 2021

Ultimate Openshift (2021) Bootcamp by School of Devops

It should work just fine. Below are more articles on OpenShift / Kubernetes environment.

Install Harbor Image Registry on Kubernetes / OpenShift with Helm Chart

Ceph Persistent Storage for Kubernetes with Cephfs

Join new Kubernetes Worker Node to an existing Cluster

How To Schedule Pods on Kubernetes Control plane (Master) Nodes

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here