In this Cloud Native Short Take, Christian Lacsina discusses how to gather information about your Kubernetes cluster from the command line using kubectl. He looks at at resources like pods running in the cluster, available resource types in the cluster, and more detailed information on specific resources in your cluster. If you’re new to Kubernetes, this video is a must-watch!
Video Transcript
Hello everyone my name is Christian Lacsina and welcome to RX-M’s latest cloud native short take. Today we will take a look at how to gather some information about your Kubernetes cluster from the command line using kubectl. Namely resources like pods running in the cluster, the available resource types in the cluster, and more detailed information on specific resources in your cluster.
So let’s begin. The most common thing I look for when going into an unfamiliar Kubernetes cluster are the pods that are running. I can see the currently running pods in my current namespace with kubectl get pods. With kubectl get pods I can quickly get a summary of the applications running in my cluster and I can take further action according to the statuses I see on the output. If I have cluster level permissions I can scope my kubectl request to specific namespaces using the --namespace or -n option. Let’s check out the pods in the kube-system namespace for example. I can even do a lookup on the entire cluster using the --all-namespaces or -A option.
Now that I have a basic listing of pods in my cluster I can further expand what information I see with the wide output which I invoke using the --output wide or -o wide options. Now i can see additional columns which include information like the ip addresses of each pod and the node that those pods are currently assigned to. So how do i know what resources i can use kubectl get on? This information is easily accessible using another command: kubectl api-resources. This command lists all the resources that i can work with in this Kubernetes cluster. This listing includes all of the standard Kubernetes resources and any custom resources that have been added to the cluster. If i run this command with the -o wide switch I get to see all the verbs that i can use to control access to these resources using role-based access control.
If there’s a resource i want to take a deeper look at then i can use kubectl get with the --output yaml option. Let’s try it. This returns a specification of the target resource in yaml format that provides an extremely detailed look at how it is deployed in the cluster. I can also use kubectl describe to get a human readable summary of that resource. In addition to the summary I can also see the cluster level events that are associated with this resource. These commands are part of the greater toolkit you can use to help debug issues on your cluster or just get a better understanding of the cluster.
You can learn more about these commands and other topics by building your own custom course on Kubernetes using the custom courseware builder.
That’s our cloud native short take on gathering information from a Kubernetes cluster using kubectl. You can also check out all of our other cloud native short takes on the RX-M youtube channel.