Debugging & Troubleshooting
Getting Started
Module Overview
Duration: 10-15 minutes
Format: Hands-on Lab - Real Problem Solving
Audience: IT Operations, SRE, Platform Engineers
Console Access
-
Username:
{openshift_cluster_admin_username} -
Password:
{openshift_cluster_admin_password} -
Console: {openshift_cluster_console_url}[window=blank]
| We recommend using the OCP Console tab within this Showroom interface as it is easier to follow along. |
Your cluster is running a weather application made up of several microservices. Some of them have just broken. Your job is to diagnose and fix each one - these are the same kinds of issues that generate real support tickets.
Learning Objectives
By the end of this module, you will be able to:
-
Read pod events and logs to identify root causes
-
Fix ImagePullBackOff, CrashLoopBackOff, ConfigMap errors, resource constraint violations, service routing issues, and SCC permission failures
-
Use the Observe → Diagnose → Fix → Verify workflow
Your Diagnostic Toolkit
These are the commands you’ll use constantly:
# What's broken?
oc get pods -n <namespace>
# Why is it broken?
oc describe pod <pod-name> -n <namespace>
# What did the app say before it died?
oc logs <pod-name> -n <namespace>
oc logs <pod-name> -n <namespace> --previous
# Check deployment events (for pods that never got created)
oc describe deployment <deployment-name> -n <namespace>
Deploy the Broken Applications
First, create the namespace and deploy the intentionally broken applications:
bash <(curl -sL https://raw.githubusercontent.com/rhpds/openshift-days-ops-showroom/main/support/05-debugging/deploy-broken-apps.sh)
See What’s Broken
Six microservices have been deployed with intentional misconfigurations. Let’s triage the damage.
Switch to the OCP Console tab and navigate to Workloads → Pods (select project debug-lab from the dropdown). You’ll immediately see which pods have issues - error states like CrashLoopBackOff and ImagePullBackOff are flagged with a red exclamation mark:
-
weather-frontend-ImagePullBackOff(red indicator) -
weather-api-CrashLoopBackOff(red indicator) -
weather-backend-CreateContainerConfigError -
weather-proxy-Running(but has a hidden issue) -
weather-cache- doesn’t appear at all
This is how real incident triage works - visual scanning of pod status to quickly identify what needs attention.
You can also verify via CLI:
oc get pods -n debug-lab
You might notice weather-cache is missing from the pod list - that’s one of the problems to investigate. Also, weather-proxy shows Running but has its own issue.
|
Your mission: Fix all six.
Fix the Problems
Problem 1: ImagePullBackOff (weather-frontend)
Diagnose
In the OCP Console, navigate to Workloads → Pods (project: debug-lab) and click on the weather-frontend pod. Click the Events tab at the top to see the error with color-coded severity - you’ll see the image pull failure immediately.
You can also check via CLI:
oc describe pod -l app=weather-frontend -n debug-lab | tail -10
Look at the Events section. You should see errors like:
Warning Failed Failed to pull image "quay.io/openshift-workshop-applications/weather-debug-app:9.9": ... manifest unknown Warning Failed Error: ImagePullBackOff
The image tag 9.9 doesn’t exist - the registry can’t find it. Let’s confirm the image reference:
oc get deployment weather-frontend -n debug-lab -o jsonpath='{.spec.template.spec.containers[0].image}'
Fix
Update the image to the correct tag (latest):
oc set image deployment/weather-frontend weather-frontend=quay.io/openshift-workshop-applications/weather-debug-app:latest -n debug-lab
Verify
oc get pods -l app=weather-frontend -n debug-lab
You should see 1/1 Running.
Takeaway: ImagePullBackOff = wrong image name, missing tag, or no pull credentials. Always check oc describe pod → Events.
Problem 2: CrashLoopBackOff (weather-api)
Diagnose
The pod keeps starting and crashing. In the OCP Console, navigate to Workloads → Pods (project: debug-lab) and click the weather-api pod, then the Logs tab. The log viewer shows the error message with real-time streaming. If the pod has restarted, use the container dropdown on the left (highlighted in red below) to select the previous container’s logs.
You can also check via CLI:
oc logs deployment/weather-api -n debug-lab
You should see:
Error: Missing required config file /etc/weather/config.yaml
The app is trying to read a config file that doesn’t exist.
Fix
Create the missing config file as a ConfigMap and mount it into the container. We’ll also fix the container command to run the actual application:
oc create configmap weather-api-config --from-literal=config.yaml="port: 8080" -n debug-lab
oc patch deployment weather-api -n debug-lab --type=json -p='[
{"op":"add","path":"/spec/template/spec/volumes","value":[{"name":"config","configMap":{"name":"weather-api-config"}}]},
{"op":"add","path":"/spec/template/spec/containers/0/volumeMounts","value":[{"name":"config","mountPath":"/etc/weather"}]},
{"op":"remove","path":"/spec/template/spec/containers/0/command"}
]'
Verify
oc get pods -l app=weather-api -n debug-lab
You should see 1/1 Running.
Takeaway: CrashLoopBackOff = the app starts then exits. Always check oc logs and oc logs --previous. Common causes: missing config, bad command, failed health checks, out of memory.
Problem 3: Resource Constraint Violation (weather-cache)
Diagnose
You may have noticed weather-cache doesn’t appear in the pod list at all. In the OCP Console, navigate to Workloads → Deployments (project: debug-lab). You’ll see weather-cache showing 0 of 1 pods - the deployment exists but no pod was created:
Click weather-cache, then the ReplicaSets tab, then click the ReplicaSet name (weather-cache-xxxxxxx). The Events tab shows the FailedCreate errors explaining why no pod was created.
Let’s also check via CLI:
oc get deployment weather-cache -n debug-lab
It shows 0/1 ready - the pod was never created. When a pod can’t even be created, check the ReplicaSet events:
oc describe replicaset -l app=weather-cache -n debug-lab | tail -5
You should see:
Warning FailedCreate ... maximum memory usage per Container is 2Gi, but limit is 1Ti
A LimitRange in the namespace caps containers at 2Gi memory, but the deployment requests 512Gi (a typo - should be 512Mi). Let’s confirm:
oc get deployment weather-cache -n debug-lab -o jsonpath='{.spec.template.spec.containers[0].resources}' | python3 -m json.tool
oc get limitrange -n debug-lab -o yaml | grep -A4 "max:"
Fix
Fix the memory typo - change 512Gi to 512Mi and 1Ti to 1Gi:
oc set resources deployment/weather-cache -n debug-lab --requests=cpu=100m,memory=512Mi --limits=cpu=500m,memory=1Gi
Verify
oc get pods -l app=weather-cache -n debug-lab
You should see 1/1 Running. The pod can now be created because the resource requests fit within the LimitRange.
Takeaway: When a pod never appears at all, check the ReplicaSet events (oc describe replicaset). LimitRanges and ResourceQuotas can silently prevent pods from being created.
Problem 4: CreateContainerConfigError (weather-backend)
Diagnose
oc describe pod -l app=weather-backend -n debug-lab | grep -E "Warning|Error|configmap"
You should see:
Warning Failed Error: configmap "weather-config" not found
The deployment references a ConfigMap that doesn’t exist:
oc get deployment weather-backend -n debug-lab -o jsonpath='{.spec.template.spec.containers[0].envFrom}' | python3 -m json.tool
Fix
Create the missing ConfigMap with the keys the app expects:
oc create configmap weather-config \
--from-literal=API_ENDPOINT="http://weather-api:8080" \
--from-literal=CACHE_TTL="300" \
-n debug-lab
You can verify the ConfigMap in the console at Workloads > ConfigMaps (project: debug-lab) - click weather-config to see its keys and values.
|
Restart the pod to pick up the new ConfigMap:
oc delete pod -l app=weather-backend -n debug-lab
Verify
oc get pods -l app=weather-backend -n debug-lab
You should see 1/1 Running. Confirm the environment variables are injected:
oc exec deployment/weather-backend -n debug-lab -- env | grep -E "API_ENDPOINT|CACHE_TTL"
You should see:
API_ENDPOINT=http://weather-api:8080 CACHE_TTL=300
| In the console, click the weather-backend pod and select the Environment tab to see the injected variables without shelling into the container. |
Takeaway: CreateContainerConfigError = a referenced ConfigMap or Secret doesn’t exist. Check oc describe pod for "not found" messages. Create the missing resource and restart the pod.
Problem 5: Service Routing Broken (weather-proxy)
Diagnose
This pod is Running - so what’s wrong? In the OCP Console, navigate to Networking → Services (project: debug-lab) and click weather-proxy. The Pods tab shows 0 Pods - immediately revealing that the service can’t find any matching pods.
Check via CLI as well:
oc get endpointslice -l kubernetes.io/service-name=weather-proxy -n debug-lab
You should see ENDPOINTS is empty (<unset>). The service has no backends.
Compare the service selector with the pod labels:
echo "=== Service selector ===" && oc get svc weather-proxy -n debug-lab -o jsonpath='{.spec.selector}' | python3 -m json.tool && echo "=== Pod labels ===" && oc get pod -l app=weather-proxy -n debug-lab -o jsonpath='{.items[0].metadata.labels}' | python3 -m json.tool
Spot the difference? The service selector says weather-proxi (typo) but the pod label is weather-proxy.
Fix
Patch the service selector to match the actual pod label:
oc patch svc weather-proxy -n debug-lab -p '{"spec":{"selector":{"app":"weather-proxy"}}}'
Verify
oc get endpointslice -l kubernetes.io/service-name=weather-proxy -n debug-lab
You should now see the pod’s IP in the ENDPOINTS column. Traffic will flow to the pod.
Takeaway: When a pod is Running but the service isn’t working, check if the service selector matches the pod labels. A single character typo can break routing. Use oc get endpointslice to verify.
You can confirm the fix in the console too - go back to Networking → Services → weather-proxy → Pods tab. The pod now appears:
Problem 6: Permission Denied (weather-db)
Diagnose
Check the pod status:
oc get pods -l app=weather-db -n debug-lab
You’ll see weather-db in CrashLoopBackOff. Check the logs:
oc logs deployment/weather-db -n debug-lab
The log shows: mkdir: cannot create directory '/var/lib/pgsql': Permission denied. The container is trying to create a data directory but doesn’t have permission.
This is a Security Context Constraint (SCC) issue. Check which SCC the pod is running under:
oc get pod -l app=weather-db -n debug-lab -o jsonpath='{.items[0].metadata.annotations.openshift\.io/scc}'
It shows restricted-v2. This SCC assigns a random user ID to the container for security - the container does NOT run as root. The directory /var/lib/pgsql is owned by root inside the image, so the random UID can’t write to it.
This is the most common source of pod failures on OpenShift. Containers that expect to run as root will fail under restricted-v2.
Fix
Mount an emptyDir volume at the data path. The container can always write to emptyDir volumes regardless of its UID:
oc patch deployment weather-db -n debug-lab --type=json -p='[
{"op":"add","path":"/spec/template/spec/volumes","value":[{"name":"db-data","emptyDir":{}}]},
{"op":"add","path":"/spec/template/spec/containers/0/volumeMounts","value":[{"name":"db-data","mountPath":"/var/lib/pgsql"}]}
]'
Verify
oc get pods -l app=weather-db -n debug-lab
The pod should now be Running. Check the logs to confirm the database initialized:
oc logs deployment/weather-db -n debug-lab
You should see [db] Starting on port 8080 - the database initialized successfully.
Takeaway: When you see Permission denied in a container log, check the SCC with oc get pod -o jsonpath='{.metadata.annotations.openshift\.io/scc}'. Under restricted-v2, containers run as a random UID and can’t write to root-owned directories. Use emptyDir volumes for writable paths, or use images designed to run as non-root.
Quick Reference
All Fixed
Switch to the OCP Console tab - Workloads → Pods (project: debug-lab). All six pods should now show green Running status. Compare this to the red/orange/yellow view you saw at the start - that visual progression is the troubleshooting workflow in action.
Verify via CLI:
oc get pods -n debug-lab
All six pods should now be Running:
NAME READY STATUS RESTARTS AGE weather-api-xxxxx 1/1 Running 0 1m weather-backend-xxxxx 1/1 Running 0 1m weather-cache-xxxxx 1/1 Running 0 1m weather-db-xxxxx 1/1 Running 0 1m weather-frontend-xxxxx 1/1 Running 0 1m weather-proxy-xxxxx 1/1 Running 0 5m
See It Working
Now that all six microservices are fixed, expose them and open the weather app:
bash <(curl -sL https://raw.githubusercontent.com/rhpds/openshift-days-ops-showroom/main/support/05-debugging/expose-weather-app.sh)
Open the URL in a new browser tab. You should see The Weather App displaying live weather data - fetched by weather-api, processed by weather-backend, cached by weather-cache, and persisted by weather-db. All six microservices working together.
| If the page shows an error on first load, wait a few seconds and refresh - the services may still be starting up. |
Quick Reference
| Status | Meaning | First Check |
|---|---|---|
ImagePullBackOff |
Can’t pull container image |
|
CrashLoopBackOff |
Container starts then crashes |
|
CreateContainerConfigError |
ConfigMap/Secret missing |
|
No pod created |
LimitRange/ResourceQuota violation |
|
Pending |
Can’t schedule pod |
|
Running but not working |
Service selector mismatch or app bug |
|
Permission denied in logs |
SCC restricts container UID |
Check SCC: |
PVC Pending |
Storage can’t be provisioned |
|
Cleanup & Summary
Summary
You diagnosed and fixed six common OpenShift issues:
-
ImagePullBackOff - wrong image tag (
9.9doesn’t exist) →oc set image -
CrashLoopBackOff - missing config file → create ConfigMap + volume mount
-
Resource constraint - memory typo exceeded LimitRange →
oc set resources -
CreateContainerConfigError - missing ConfigMap →
oc create configmap -
Service selector mismatch - typo in selector →
oc patch svc -
SCC permission denied - container can’t write to root-owned directory → mount
emptyDirvolume
The pattern is always the same: check status → describe pod/replicaset → read logs/events → fix → verify.








