How to View a Pod in Kubernetes

How to View and Interact with a Pod in Kubernetes

Well, in Kubernetes, the pods are what really run containers. The rest of the infra is almost there to make sure that this happens. So that is why knowing how to find a pod, being able to retrieve its Kubernetes configuration and status, being able to retrieve logs as well as SSH to their containers is essential for any Kubernetes management.

In this tutorial we are going to use kubectl, But to let you this is a 100% easier if we use a Kubernetes ui as K8studio

Ok, let's go.

1. how to get a list of pods

So the first thing is how I find the pod I'm looking for:

To list all pods in the default namespace:

kubectl get pods

To view pods in a specific namespace, add the -n flag:

kubectl get pods -n <namespace>

To list all pods in the all the name spaces :

kubectl get pods --all-namespaces

or

kubectl get pods -A

If we execute any of the above commands we will get an output similar to this:

NAMESPACE     NAME                                    READY   STATUS    RESTARTS   AGE
kube-system   coredns-558bd4d5db-l7m5s                1/1     Running   0          3d2h
kube-system   kube-proxy-gke-cluster-default-pool     1/1     Running   0          3d2h
default       my-app-deployment-74c9c8cfc9-vkjfg      1/1     Running   2          5h12m
default       my-app-deployment-74c9c8cfc9-xjktz      1/1     Running   1          5h12m
dev           api-server-6fbb78d865-4md7k             1/1     Running   0          22h
dev           redis-84d97f6db4-xm92j                  1/1     Running   0          22h
monitoring    prometheus-server-69fdcbcb46-rt7sw      2/2     Running   0          2d6h

if the list is too long and we have an ide of what is the pod name we can use grep to filter the result

kubectl get pods -A | grep api

Now that we know the name of the pod we can do this to obtain more info:

kubectl get pod <pod-name> -n <namespace>

This command shows a quick summary of the pod’s status.

NAME                        READY   STATUS    RESTARTS   AGE
my-app-7d8d6f8d7b-w2xqz     1/1     Running   0          3h12m

But this is of then not enough, if we want more details we will need to ask for a description of the pod

2. Describing a Pod in Detail

For in-depth information about a pod (events, volumes, container status, resource requests, etc.):

kubectl describe pod <pod-name> -n <namespace>

This is will give us a result like this:

Name:           my-app-7d8d6f8d7b-w2xqz
Namespace:      default
Priority:       0
Node:           worker-node-1/192.168.1.10
Start Time:     Fri, 27 Jun 2025 09:22:17 +0000
Labels:         app=my-app
                pod-template-hash=7d8d6f8d7b
Annotations:    <none>
Status:         Running
IP:             10.44.0.15
IPs:
  IP:           10.44.0.15
Controlled By:  ReplicaSet/my-app-7d8d6f8d7b
Containers:
  my-app-container:
    Container ID:   docker://a1b2c3d4e5f6
    Image:          my-app-image:latest
    Image ID:       docker-pullable://my-app-image@sha256:abc123...
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Fri, 27 Jun 2025 09:22:21 +0000
    Ready:          True
    Restart Count:  0
    Limits:
      cpu:     500m
      memory:  256Mi
    Requests:
      cpu:     100m
      memory:  128Mi
    Environment:
      ENV:  production
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-5phvn (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-5phvn:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds: 3607
QoS Class:       Burstable
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  3h    default-scheduler  Successfully assigned default/my-app-7d8d6f8d7b-w2xqz to worker-node-1
  Normal  Pulling    3h    kubelet            Pulling image "my-app-image:latest"
  Normal  Pulled     3h    kubelet            Successfully pulled image "my-app-image:latest"
  Normal  Created    3h    kubelet            Created container my-app-container
  Normal  Started    3h    kubelet            Started container my-app-container

Here there is alot more information, about the specification, the status and the event associated with the pods

But this does not help us if we want to really find out why an application is not working as expected:

For that we need logs

3. To View a Pod Logs

To view logs from the pod's container:

kubectl logs <pod-name> -n <namespace>

If the pod has multiple containers, specify the container name:

kubectl logs <pod-name> -c <container-name> -n <namespace>

To stream logs in real-time (like tail -f):

kubectl logs -f <pod-name> -n <namespace>

In some cases this is not enough and we need to connect on ssh to the pod

4. Executing Commands Inside a Pod (SSH-like Access)

You can exec into a container running inside a pod using:

kubectl exec -it <pod-name> -- /bin/bash -n <namespace>

Or use /bin/sh if Bash is not available:

kubectl exec -it <pod-name> -- /bin/sh -n <namespace>

If the pod has multiple containers:

kubectl exec -it <pod-name> -c <container-name> -- /bin/bash -n <namespace>

This gives you direct access to the container’s shell — great for debugging and manual inspection.

Summary of Common Commands

Task Command Example

List all pods kubectl get pods -n <namespace>

View one pod kubectl get pod <pod-name> -n <namespace>

Describe a pod kubectl describe pod <pod-name> -n <namespace>

View pod logs kubectl logs <pod-name> -n <namespace>

View logs (multi-container) kubectl logs <pod-name> -c <container-name> -n <namespace>

Tail logs kubectl logs -f <pod-name> -n <namespace>

Exec into container kubectl exec -it <pod-name> -- /bin/bash -n <namespace>

Exec (multi-container) kubectl exec -it <pod-name> -c <container-name> -- /bin/bash -n <namespace>