Here is a quick-reference CLI cheat sheet organized by operational domain for day-to-day OpenShift Container Platform (OCP) administration and troubleshooting.
1. Cluster & Operator Health Checks
Bash
# Check status of all Core Operators (Look for DEGRADED=True or AVAILABLE=False)oc get clusteroperators# Check overall node status and OS versionsoc get nodes -o wide# Check cluster version status and historyoc get clusterversion# View cluster-wide active alertsoc get alerts# Check cluster event log sorted by timestampoc get events -A --sort-by='.metadata.creationTimestamp' | tail -n 30
2. Node & Machine Management
Bash
# Get MachineConfigPool (MCP) status (Check if UPDATING=True or DEGRADED=True)oc get mcp# View machine config rendered versionsoc get machineconfig# Inspect detailed node resource capacity and usageoc describe node <node-name>oc adm top nodes# Cordon and drain a node for maintenanceoc adm cordon <node-name>oc adm drain <node-name> --ignore-daemonsets --delete-emptydir-data# Uncordon node after maintenanceoc adm uncordon <node-name>
3. Pod & Workload Troubleshooting
Bash
# Find pods not in Running/Completed state across all namespacesoc get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded# Show top CPU and memory consuming podsoc adm top pods -A --sort-by=memory# View logs for a failing pod (current container)oc logs <pod-name> -n <namespace> -c <container-name># View logs for a PREVIOUS crashed container instance (CrashLoopBackOff)oc logs <pod-name> -n <namespace> -c <container-name> --previous# Stream logs across all pods matching a labeloc logs -l app=my-app -n <namespace> --all-containers --tail=100 -f# Get detailed lifecycle events for a stuck/failing podoc describe pod <pod-name> -n <namespace>
4. Advanced Live Debugging & Shell Access
Bash
# Launch a debug pod using the exact spec of a failing application podoc debug pod/<pod-name> -n <namespace># Attach an ephemeral debug container with nettools (nicolaka/netshoot) to a running podoc debug pod/<pod-name> -n <namespace> --image=nicolaka/netshoot --target=<container-name> -it# Spawn a root debug shell on a specific host nodeoc debug node/<node-name># Inside the debug pod, switch to host filesystem:# chroot /host# Execute interactive bash directly inside a running containeroc exec -it <pod-name> -n <namespace> -c <container-name> -- /bin/bash
5. Networking & Ingress Debugging
Bash
# Check DNS Operator and CoreDNS pod statusoc get clusteroperator dnsoc get pods -n openshift-dns -o wide# Inspect OpenShift Ingress Routersoc get pods -n openshift-ingress -o wideoc get routes -A# Test internal DNS resolution from a temporary podoc run dns-test --image=registry.redhat.io/rhel8/support-tools --rm -it -- dig <service-name>.<namespace>.svc.cluster.local# View dropped NetworkPolicy logs on OVN-Kubernetes hostoc debug node/<node-name> -- chroot /host journalctl -u ovs-vswitchd -f | grep -i "drop"# Capture host network traffic via host debug shelloc debug node/<node-name> -- chroot /host nsenter -t $(crictl inspect --output json $(crictl ps --name <container-name> -q) | jq '.info.pid') -n tcpdump -i any -nn
6. Storage & PVC Diagnostics
Bash
# List all PVCs across the cluster that are Pending or Degradedoc get pvc -A | grep -v Bound# Inspect StorageClasses and default provisionersoc get sc# View VolumeAttachment objects and CSI node statusoc get volumeattachmentsoc get csinodes
7. etcd & Control Plane Recovery
Bash
# Check etcd pod statusoc get pods -n openshift-etcd -l app=etcd# Execute etcdctl health check inside an etcd containeroc exec -n openshift-etcd -c etcd $(oc get pods -n openshift-etcd -l app=etcd -o jsonpath='{.items[0].metadata.name}') -- etcdctl endpoint health --cluster# View etcd member listoc exec -n openshift-etcd -c etcd $(oc get pods -n openshift-etcd -l app=etcd -o jsonpath='{.items[0].metadata.name}') -- etcdctl member list -w table
8. Enterprise Diagnostic Data Collection (must-gather)
Bash
# Collect standard OpenShift diagnostic bundle (Saved to ./must-gather.local)oc adm must-gather# Run must-gather for a specific operator (e.g., ODF / Storage)oc adm must-gather --image=registry.redhat.io/odf4/odf-must-gather-rhel8# Save must-gather output to a specific directoryoc adm must-gather --dest-dir=./cluster-debug-logs