Pods
Pods – Pods are the smallest deployable units of computing that you can create and manage in Kubernetes. A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers.
List one or more pods.
kubectl get pod
List pods Sorted by Restart Count.
kubectl get pods --sort-by='.status.containerStatuses[0].restartCount'
Get all running pods in the namespace.
kubectl get pods --field-selector=status.phase=Running
Delete a pod.
kubectl delete pod <pod_name>
Display the detailed state of a pods.
kubectl describe pod <pod_name>
Create a pod.
kubectl create pod <pod_name>
Execute a command against a container in a pod.
kubectl exec <pod_name> -c <container_name> <command>
Get an interactive shell on a single-container pod.
kubectl exec -it <pod_name> /bin/sh
Display Resource usage (CPU/Memory/Storage) for pods.
kubectl top pod
Add or update the annotations of a pod.
kubectl annotate pod <pod_name> <annotation>
Add or update the label of a pod.
kubectl label pods <pod_name> new-label=<label name>
Get pods and show labels.
kubectl get pods --show-labels
Listen on a port on the local machine and forward to a port on a specified pod.
kubectl port-forward <pod name> <port number to listen on>:<port number to forward to>
Last updated