CloudOpsGuide
kubernetes

kubectl get pods all namespaces: Complete Guide

Beginner
8 minutes
October 2026
CloudOpsGuide Team

kubectl get pods all namespaces: Complete Guide

Learn how to list pods across all Kubernetes namespaces using kubectl with practical examples and troubleshooting tips.

Table of Contents

Basic Command

The simplest way to list all pods across all namespaces:

kubectl get pods --all-namespaces

Or using the shorter alias:

kubectl get pods -A

Output Explanation

NAMESPACE     NAME                       READY   STATUS    RESTARTS   AGE
default       nginx-7db9fccd9b-2x4kl     1/1     Running   0          2d
kube-system   coredns-5644d7b6d9-k8w9v   1/1     Running   0          2d
kube-system   etcd-minikube              1/1     Running   0          2d
  • NAMESPACE: Which namespace the pod belongs to
  • NAME: Unique name of the pod
  • READY: Running containers / Total containers
  • STATUS: Current pod status (Running, Pending, Failed, etc.)
  • RESTARTS: Number of container restarts
  • AGE: How long the pod has been running

Filtering Results

Filter by Namespace

# Specific namespace
kubectl get pods -n kube-system

# Multiple namespaces
kubectl get pods -n kube-system -n default

Filter by Label

# All pods with specific label
kubectl get pods --all-namespaces -l app=nginx

# Multiple labels
kubectl get pods --all-namespaces -l app=nginx,tier=frontend

Filter by Status

# Only running pods
kubectl get pods --all-namespaces --field-selector=status.phase=Running

# Only failed pods
kubectl get pods --all-namespaces --field-selector=status.phase=Failed

Filter by Age

# Pods older than 1 hour
kubectl get pods --all-namespaces --field-selector=status.phase!=Succeeded

Common Use Cases

1. Find CrashLoopBackOff Pods

kubectl get pods --all-namespaces --field-selector=status.phase!=Running

2. Check Resource Usage

kubectl top pods --all-namespaces

3. Find Pods with High Restart Counts

kubectl get pods --all-namespaces --sort-by='.status.containerStatuses[0].restartCount'

4. List Pods with Their IPs

kubectl get pods --all-namespaces -o wide

5. Get Pod Details in JSON

kubectl get pods --all-namespaces -o json

Troubleshooting

Pod Not Showing Up

If a pod isn't appearing in the list:

  1. Check if it exists in a specific namespace:
kubectl get pods -n <namespace>
  1. Verify you have permissions:
kubectl auth can-i list pods --all-namespaces
  1. Check if namespace exists:
kubectl get namespaces

Command Timeout

If the command times out:

# Increase timeout
kubectl get pods --all-namespaces --request-timeout=30s

Too Many Results

When dealing with large clusters:

# Limit results
kubectl get pods --all-namespaces --limit=50

# Watch mode for real-time updates
kubectl get pods --all-namespaces --watch

Best Practices

1. Use Context Switching

# List contexts
kubectl config get-contexts

# Switch context
kubectl config use-context <context-name>

2. Create Aliases

Add to your ~/.bashrc or ~/.zshrc:

alias k='kubectl'
alias kga='kubectl get pods --all-namespaces'
alias kg='kubectl get pods'

3. Use kubectl Plugins

Install kubectl plugins for enhanced functionality:

# Install krew (kubectl plugin manager)
kubectl krew install krew
kubectl krew install get-all

4. Label Your Resources

Always label your pods for easier filtering:

kubectl label pod <pod-name> environment=production app=nginx

Advanced Examples

Get Pods with Custom Columns

kubectl get pods --all-namespaces \
  -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,IP:.status.podIP

Export Pod List to CSV

kubectl get pods --all-namespaces -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,STATUS:.status.phase \
  --no-headers | tr ' ' ',' > pods.csv

Find Pods Using Specific Node

kubectl get pods --all-namespaces --field-selector=spec.nodeName=<node-name>

List Pods with Image Information

kubectl get pods --all-namespaces -o custom-columns=NAME:.metadata.name,IMAGE:.spec.containers[*].image

Summary

CommandDescription
kubectl get pods -AList all pods across all namespaces
kubectl get pods -n <namespace>List pods in specific namespace
kubectl get pods --all-namespaces -l <label>Filter by label
kubectl get pods --all-namespaces -o wideShow additional information
kubectl top pods --all-namespacesShow resource usage

Related Commands

  • kubectl describe pod <pod-name> - Get detailed pod information
  • kubectl logs <pod-name> - View pod logs
  • kubectl exec -it <pod-name> -- /bin/bash - Execute command in pod
  • kubectl delete pod <pod-name> - Delete a pod

Common Errors and Solutions

Error: "No resources found"

Cause: No pods in the cluster or wrong namespace Solution: Check namespaces and cluster status

Error: "User 'system:anonymous' cannot list pods"

Cause: Insufficient permissions Solution: Configure proper RBAC or use admin context

Error: "the server has asked for the client to provide credentials"

Cause: Authentication issues Solution: Re-authenticate with kubectl login or update kubeconfig

Next Steps


Last Updated: October 2026
Author: CloudOpsGuide Team
Difficulty: Beginner
Estimated Reading Time: 8 minutes