Pods are the smallest deployable units in Kubernetes and run inside nodes.
- A node can have multiple Pods.
- To deploy more Pods, new nodes can be created.
- Pods have a one-to-one relationship with containers, but they are not restricted to a single container.
- Additional helper containers can be included for tasks like managing user data.
- Pods within the same node can share:
- Storage
- Information
- Pods in the same node are part of the same network namespace, allowing them to communicate easily.
- List all Pods in the default namespace:
kubectl get pods
- List Pods in a specific namespace:
kubectl get pods -n <namespace>
- View detailed information about a Pod:
kubectl describe pod <pod-name>
- Create a Pod using a YAML file:
kubectl apply -f pod-definition.yml
- Delete a specific Pod:
kubectl delete pod <pod-name>
- Delete all Pods in a namespace:
kubectl delete pods --all -n <namespace>
- View logs for a Pod:
kubectl logs <pod-name>
- View logs for a specific container in a Pod:
kubectl logs <pod-name> -c <container-name>
- Access the shell of a Pod’s container:
kubectl exec -it <pod-name> -- /bin/bash
- Run a command inside a Pod:
kubectl exec <pod-name> -- <command>
- Check events related to a Pod:
kubectl describe pod <pod-name>
- Check the Pod status:
kubectl get pods <pod-name> -o wide
- Watch changes in Pod states:
kubectl get pods -w