Cluster Health

Check OCP pods resource utilisation

# get resource utilization of all pods across all namespace.
# appending --sum will output sum of cpu and memory at end of command output
oc adm top pod -A --sum`
# we can also get the resource utilization of containers within each running pods too by appending --containers to command

oc adm top pod pod_name -n namespace_name --containers

Check logs of node services

# node-logs will output logs of all services in the node
oc adm node-logs master01 

# appending -u service_name will only output lgos of the service in the node
oc adm node-logs master01 -u crio --tail 1

Create debug session into node

oc debug node/master01

# a pod will be created and some prompts will be shown on screen. Enter `chroot /host` to access host binaries

chroot /host

systemctl status kubelet

# check if a service is active
systemctl is-active kubelet

Gather Debug logs

# Gather logs for cluster
oc adm must-gather --dest-dir /home/student/must-gather

# Generate logs for specific resources
oc adm inspect clusteroperator/kube-apiserver --dest-dir /home/student/inspect --since 5m

Get API resources in cluster

# appending --namespaced will only show resources that are namespace scoped
oc api-resources --namespaced

# to only list resources belonging to certain API group
oc api-resources --api-group oauth.openshift.io

# to only list resources belonging to core API group
oc api-resources --api-group ''