kubectl get pods example

The kubectl get pods command is used to retrieve information about pods in a Kubernetes cluster.

Here is an example of how you can use the kubectl get pods command to get information about all pods in the default namespace:

kubectl get pods

This command will display a list of all pods in the default namespace along with their current status. The output will look similar to this:

NAME READY STATUS RESTARTS AGE my-pod 1/1 Running 0 2d

The output includes the name of the pod, the number of containers in the pod that are currently running and the total number of containers in the pod, the current status of the pod, the number of times the pod has been restarted, and the age of the pod.

You can also use the kubectl get pods -n namespace to get information about pods in a specific namespace, for example,

kubectl get pods -n kube-system

You can also filter the pods by using a label selector, for example,

kubectl get pods --selector=app=my-app

This command will display only the pods that have the label "app" set to "my-app".

These are just a few examples of how you can use the kubectl get pods command. There are many more options and arguments available, and the best way to learn more is to explore the Kubernetes documentation and try out different commands on your own.

Previous Post Next Post