Version note: examples use the Kubernetes v1.35 documentation snapshot, not necessarily the newest release. Check current support and component compatibility. These commands were not tested on a live cluster.
What this guide covers
After scheduling, the kubelet on the selected node asks the container runtime to start the Pod. CRI is the interface to that runtime. CNI plugins configure Pod networking. Failures at these stages produce different Pod events.
Before you start
Use a working test cluster and create node-lab. Node-level commands require sudo on the machine hosting the Pod. This example uses containerd.
Step 1: Create a test Pod
Save this as pod.yaml and apply it with kubectl apply -f pod.yaml:
apiVersion: v1
kind: Pod
metadata:
name: lifecycle-demo
namespace: node-lab
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 30
containers:
- name: web
image: nginx:1.28.0
ports:
- name: http
containerPort: 80
resources:
requests:
cpu: 100m
memory: 64Mi
limits:
memory: 128Mi
startupProbe:
httpGet:
path: /
port: http
failureThreshold: 30
periodSeconds: 2
readinessProbe:
httpGet:
path: /
port: http
periodSeconds: 5
livenessProbe:
httpGet:
path: /
port: http
periodSeconds: 10
Step 2: Read Pod events and logs
Run:
kubectl -n node-lab describe pod lifecycle-demo
kubectl -n node-lab logs lifecycle-demo -c web
kubectl -n node-lab logs lifecycle-demo -c web --previous
kubectl -n node-lab get pod lifecycle-demo -o wide
A failed image pull concerns the image or registry. A sandbox network error points toward Pod networking. An application exit should be investigated through the container logs. --previous works only if a previous container instance exists.
Step 3: Check the selected node
On the node shown by the Pod’s wide output, run:
sudo systemctl status kubelet containerd --no-pager
sudo journalctl -u kubelet -n 100 --no-pager
sudo journalctl -u containerd -n 100 --no-pager
sudo crictl --runtime-endpoint unix:///run/containerd/containerd.sock info
sudo crictl --runtime-endpoint unix:///run/containerd/containerd.sock ps -a
Match runtime errors to the Pod and time of failure. Do not delete runtime directories or restart every node before recording the error.
Check the result
The test Pod should become Ready. If not, identify whether image download, network setup or the application failed, then fix that stage and check the new events.
Conversation
0 commentsNo comments yet. Start the conversation below.