MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

OpenShift Lab 10: View Pod, Workload, and Namespace Performance Metrics Using the OpenShift Web Console

This lab uses the OpenShift web console to view CPU, memory, network and pod metrics for one namespace and its workloads. It then checks the same numbers from the CLI. The sections below add what the steps above leave out: how to enable monitoring on OpenShift Local, YAML for a web app and for the rpjob Job that oc logs job/rpjob expects, ready-to-run PromQL queries, expected output and fixes for common problems.

OpenShift Lab 10: View Pod, Workload, and Namespace Performance Metrics Using the OpenShift Web Console

Updated lab flow

  1. Start OpenShift Local.
  2. Log in to the web console.
  3. Create project lab10-performance-demo.
  4. Deploy a lightweight web app or resource-pressure Job.
  5. View pods and workload details in Topology.
  6. Open Observe โ†’ Dashboards.
  7. Select dashboard:Kubernetes / Compute Resources / Namespace (Workloads)
  8. View CPU, memory, network receive/transmit, pod count, and workload metrics.
  9. Use Observe โ†’ Metrics to run simple PromQL queries.
  10. Validate from CLI using:
oc get pods
oc get jobs
oc logs job/rpjob
oc adm top pods
Code language: JavaScript (javascript)
  1. Explain why metrics may take 30โ€“60 seconds to appear.
  2. Clean up the project.

One important update: Red Hatโ€™s monitoring docs note that from OpenShift 4.19 onward, the web console perspectives changed and the Developer perspective is no longer enabled by default in the same way, so our lab should avoid depending too heavily on old Developer Sandbox screenshots. We can still mention Developer/Administrator views, but we should write the steps flexibly for the current console. (Red Hat Documentation)


Before you start: enable cluster monitoring on OpenShift Local

OpenShift Local (CRC) turns off the cluster monitoring stack by default to save memory. If it stays off, Observe โ†’ Dashboards and Observe โ†’ Metrics show no data, and oc adm top pods reports that metrics are not available. Monitoring needs more memory than the default setting, so give the VM at least 14 GiB before you start it.

  • OpenShift Local installed with the openshift preset (MicroShift does not include this console monitoring stack).
  • A host with enough free RAM for a 14 GiB VM, and at least 4 vCPUs.
  • The oc CLI. crc oc-env gives you one.
# Stop the instance if it is running
crc stop

# Enable monitoring and give the VM enough memory (value in MiB)
crc config set enable-cluster-monitoring true
crc config set memory 14336

# Start the cluster and put oc on your PATH
crc start
eval $(crc oc-env)

# Show console URL and login credentials
crc console --credentials

# Log in as the developer user
oc login -u developer -p developer https://api.crc.testing:6443Code language: PHP (php)

Note: After crc start, the monitoring pods can take a few minutes to become ready. To check them, log in as kubeadmin and run oc get pods -n openshift-monitoring. Wait until the prometheus-k8s-* and thanos-querier-* pods are Running.

Create the project and deploy workloads

Step 4 above offers a choice between a web app and a resource-pressure Job. Deploy both. The web app gives you network traffic and a steady low baseline. The Job, named rpjob to match the oc logs job/rpjob command above, uses CPU for five minutes so the graphs have something to show.

oc new-project lab10-performance-demo

# Lightweight web app (UBI httpd listens on 8080)
oc create deployment web --image=registry.access.redhat.com/ubi9/httpd-24 --port=8080
oc set resources deployment/web --requests=cpu=50m,memory=64Mi --limits=cpu=200m,memory=256Mi
oc expose deployment web --port=8080
oc expose service web
oc get route webCode language: PHP (php)

Save the following as rpjob.yaml. The container runs a busy loop that is capped by its CPU limit, so it pushes CPU usage up to about 500m without affecting the rest of the cluster. The securityContext meets the restricted pod security profile, so OpenShift does not show admission warnings.

apiVersion: batch/v1
kind: Job
metadata:
  name: rpjob
spec:
  backoffLimit: 0
  ttlSecondsAfterFinished: 1800
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: cpu-burn
        image: registry.access.redhat.com/ubi9/ubi-minimal
        command: ["bash", "-c"]
        args:
        - |
          echo "rpjob: starting 300s CPU load"
          end=$((SECONDS+300))
          while [ $SECONDS -lt $end ]; do :; done
          echo "rpjob: finished"
        resources:
          requests:
            cpu: 100m
            memory: 32Mi
          limits:
            cpu: 500m
            memory: 64Mi
        securityContext:
          allowPrivilegeEscalation: false
          runAsNonRoot: true
          capabilities:
            drop: ["ALL"]
          seccompProfile:
            type: RuntimeDefaultCode language: PHP (php)
oc apply -f rpjob.yaml

# Generate some HTTP traffic for the network panels
HOST=$(oc get route web -o jsonpath='{.spec.host}')
for i in $(seq 1 500); do curl -s -o /dev/null http://$HOST/; doneCode language: PHP (php)

In Topology, select the web Deployment and the rpjob Job. The side panel shows the pod status. Open a pod and go to its Metrics tab for small CPU, memory and network graphs for that pod. For more on Job fields such as backoffLimit and ttlSecondsAfterFinished, see Kubernetes Job & CronJob Explained.

Reading the namespace workloads dashboard

Open Observe โ†’ Dashboards, select the project lab10-performance-demo if asked, and choose Kubernetes / Compute Resources / Namespace (Workloads). Set the time range to the last 15 or 30 minutes. Where the dashboard has a workload type filter, set it to deployment or job. The menu location depends on your console version and perspective: from OpenShift 4.19 onward, look for Observe in the main navigation rather than relying on the older Developer perspective layout.

PanelWhat it showsWhat to expect in this lab
CPU UsageCPU cores used per workload over timerpjob near 0.5 cores while it runs, web close to 0
CPU QuotaUsage compared with requests and limitsrpjob usage well above its 100m request and at its 500m limit
Memory UsageWorking set memory per workloadweb tens of MiB, rpjob only a few MiB
Memory QuotaMemory usage compared with requests and limitsBoth well under their limits
Receive / Transmit BandwidthNetwork bytes per second per workloadA short spike on web while the curl loop runs
Running podsNumber of pods per workload1 for web, 1 for rpjob until it completes

Query metrics with PromQL in Observe โ†’ Metrics

Observe โ†’ Metrics runs PromQL against the cluster Prometheus through Thanos Querier. If you are not a cluster admin, results are limited to the project you select, so make sure lab10-performance-demo is the active project. Paste each query and click Run queries.

# CPU cores used per pod (5-minute rate)
sum by (pod) (rate(container_cpu_usage_seconds_total{namespace="lab10-performance-demo", container!="", container!="POD"}[5m]))

# Memory working set per pod, in bytes
sum by (pod) (container_memory_working_set_bytes{namespace="lab10-performance-demo", container!="", container!="POD"})

# Network receive bytes per second per pod
sum by (pod) (rate(container_network_receive_bytes_total{namespace="lab10-performance-demo"}[5m]))

# Pod count by phase
sum by (phase) (kube_pod_status_phase{namespace="lab10-performance-demo"})Code language: PHP (php)

The container!="" filter drops the pod-level cgroup series. Without it, the totals count the same CPU twice. rate(...[5m]) turns a counter that only increases into a per-second value. A shorter window such as [1m] reacts faster but gives a noisier line.

Validate from the CLI

oc project lab10-performance-demo
oc get pods
oc get jobs
oc logs job/rpjob
oc adm top podsCode language: JavaScript (javascript)

While the Job is running, the output looks similar to the example below. Pod name suffixes and exact values will differ.

$ oc get jobs
NAME    STATUS    COMPLETIONS   DURATION   AGE
rpjob   Running   0/1           2m10s      2m10s

$ oc logs job/rpjob
rpjob: starting 300s CPU load

$ oc adm top pods
NAME                   CPU(cores)   MEMORY(bytes)
rpjob-7xk2p            499m         1Mi
web-6d9c8b7f5d-q4lmn   1m           38MiCode language: JavaScript (javascript)

oc adm top pods reads the Kubernetes metrics API (metrics.k8s.io), not Prometheus directly, so its numbers will be close to the dashboard but may not match exactly. Once the Job completes, oc get jobs reports it as complete and the pod drops out of oc adm top output.

Why metrics take 30 to 60 seconds to appear

  • Scrape interval: Prometheus collects container metrics from the kubelet on a fixed schedule, usually about every 30 seconds. A new pod has no data until its first scrape.
  • Rate needs two samples: CPU and network graphs use rate(), which needs at least two data points. That can add another full scrape interval.
  • Metrics API window: oc adm top reports usage averaged over a recent window, so new pods show metrics not available yet at first.
  • Dashboard refresh: The console polls on its own refresh interval. Click refresh or shorten the interval if a graph looks stale.

Common problems and fixes

SymptomLikely causeFix
Dashboards show No datapoints foundCluster monitoring is turned off in OpenShift LocalRun crc config set enable-cluster-monitoring true, set memory to 14336, then restart
error: metrics not available yet from oc adm top podsPods are too new, or monitoring is not runningWait a minute and retry, then check pods in openshift-monitoring
Observe menu or dashboard not visibleConsole perspective changed, or your user lacks permissionLook for Observe in the main navigation, select the correct project, and log in as a user with access to the project
PromQL returns nothing for a developer userNo project selected, or wrong namespace labelSelect lab10-performance-demo and check the namespace value in the query
rpjob pod stuck in PendingNot enough CPU or memory to schedule itRun oc describe pod, then lower requests or give CRC more CPUs with crc config set cpus 6
Pod security warnings when applying YAMLMissing restricted securityContext fieldsUse the securityContext from the manifest above

Clean up

oc delete project lab10-performance-demo

# Optional: stop the cluster to free host memory
crc stopCode language: PHP (php)

Deleting the project removes the Deployment, Service, Route and Job together. Historical metrics for the namespace stay in Prometheus until normal retention removes them.

Corrections to the lab flow above

  • The flow runs oc logs job/rpjob but never creates a Job named rpjob. The manifest above defines it.
  • Steps 1 to 4 contain no commands. Commands to start CRC, log in, create the project and deploy workloads are added above.
  • OpenShift Local turns off cluster monitoring by default, so the dashboards and oc adm top show no data unless you enable it and raise the VM memory first.
  • The CLI validation commands assume the lab project is active. Run oc project lab10-performance-demo first or add -n lab10-performance-demo.

Frequently asked questions

Why does the OpenShift Local console show no metrics?

OpenShift Local turns off cluster monitoring by default. Run crc config set enable-cluster-monitoring true, give the VM at least 14 GiB of memory, and restart the cluster.

What is the difference between oc adm top pods and the Observe dashboards?

oc adm top pods shows the current usage from the Kubernetes metrics API. The Observe dashboards query Prometheus history, so you can see trends, compare usage with requests and limits, and view network traffic.

Can a non-admin user view namespace metrics in OpenShift?

Yes. A user with access to a project can open Observe dashboards and run PromQL queries limited to that project. Cluster-wide queries need extra monitoring permissions.

Which dashboard shows CPU and memory per Deployment in OpenShift?

Use Kubernetes / Compute Resources / Namespace (Workloads). It groups usage by workload, such as Deployment, StatefulSet or Job, and compares it with requests and limits.

Why does my new pod not appear in the metrics graphs right away?

Prometheus scrapes container metrics on an interval, usually about 30 seconds, and rate-based graphs need at least two samples. A delay of up to about a minute is normal.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

OpenShift – Practical Guide to NetworkPolicy

URL – https://www.devopsschool.com/blog/kubernetes-cks-network-policy-example-code/ ๐Ÿ” OpenShift NetworkPolicies Tutorial (with httpd in test2 namespace) ๐ŸŽฏ Goal You will: โœ… Deploy an httpd serverโœ… Launch test clients to access itโœ……

Read More

Kubernetes ResourceQuota & LimitRange Example Programs

Kubernetes ResourceQuota and LimitRange are two important mechanisms for managing resource allocation and usage within a Kubernetes cluster. Here’s a comparison of ResourceQuota and LimitRange features and…

Read More

Kubernetes API Reference: Complete Guide

Namespaces Working with Kubernetes Cluster using Kubectl Part โ€“ 6 โ€“ Namespaces Pod Kubernetes Pod Example Programs Working with Kubernetes Pods & Deployment Kubernetes POD observability and…

Read More

Kubernetes Interview Questions and Answer Part โ€“ 2

How you will link when the docker containers is in different virtual machine is there any configuration in docker compose file are any command or any variable?…

Read More

Kubernetes Assignment and Project

This page is a five-day Kubernetes assignment. It starts with architecture and Pods, then moves through ReplicaSets, DaemonSets, Deployments, Services, CoreDNS service discovery and StatefulSets, and ends…

Read More

Helm Tutorials: How to create Basic Custom Charts

This tutorial shows how to build a minimal custom Helm chart: scaffold it with helm create, remove the default templates, add your own Pod template, set chart…

Read More
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
1 month ago

The OpenShift web console makes performance checks easier when teams know which metrics matter most. Watching CPU and memory use alongside pod restarts can help identify resource pressure early. It is useful to compare current readings with normal workload patterns instead of reacting to a single spike. Teams should also check resource requests and limits when a pod consistently runs near capacity. Recording findings during the lab builds good habits for diagnosing performance issues in real clusters.

Jason Mitchell
Jason Mitchell
8 months ago

Very helpful and practical guide! The steps to view performance information using the OpenShift web console are explained clearly, making it easier for beginners and admins to monitor cluster metrics and resource usage. A useful resource for anyone learning OpenShift management.

2
0
Would love your thoughts, please comment.x
()
x