Lifecycle Policy — control Pod lifecycle behavior like orphaned Pod handling.
1apiVersion: apps/v12kind: Deployment3metadata:4 name: myapp5spec:6 replicas: 37 template:8 metadata:9 labels:10 app: myapp11 spec:12 terminationGracePeriodSeconds: 3013 activeDeadlineSeconds: 360014 containers:15 - name: app16 image: myapp:latest17 lifecycle:18 postStart:19 exec:20 command: ["sh", "-c", "echo started > /tmp/ready"]21 preStop:22 exec:23 command: ["sh", "-c", "sleep 5 && kill -TERM 1"]24 startupProbe:25 httpGet:26 path: /healthz27 port: 808028 failureThreshold: 3029 periodSeconds: 1030 readinessProbe:31 httpGet:32 path: /ready33 port: 808034 initialDelaySeconds: 535 periodSeconds: 1036 livenessProbe:37 httpGet:38 path: /healthz39 port: 808040 initialDelaySeconds: 1541 periodSeconds: 20
1# Check Pod conditions2kubectl get pod my-pod -o jsonpath='{.status.conditions}' | jq34# Check restart count5kubectl get pod my-pod -o jsonpath='{.status.containerStatuses[*].restartCount}'67# Check last state8kubectl get pod my-pod -o jsonpath='{.status.containerStatuses[*].lastState}' | jq910# Force delete stuck Pod11kubectl delete pod my-pod --force --grace-period=01213# Check events14kubectl get events --field-selector involvedObject.name=my-pod
Conditions:
Probes: