sh
kubectl get pods -n caverns-x1cyjdRESTARTS keeps rising. Describe the Pod and read the Liveness: line and the Events:
sh
kubectl describe pod <market-web-pod> -n caverns-x1cyjdtext
Liveness: http-get http://:80/healthz ... #failure=3
Events:
Warning Unhealthy Liveness probe failed: HTTP probe failed with statuscode: 404
Normal Killing Container web failed liveness probe, will be restartednginx serves /. It has no /healthz. Every probe is a 404; every third 404 is a restart.
Fix the path
Apply the Deployment with the probe pointed at /:
sh
kubectl apply -n caverns-x1cyjd -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: market-web
spec:
replicas: 1
selector:
matchLabels:
app: market-web
template:
metadata:
labels:
app: market-web
spec:
containers:
- name: web
image: nginx:1.27
ports:
- containerPort: 80
livenessProbe:
httpGet:
path: /
port: 80
periodSeconds: 5
EOFAdd readiness
Same manifest, plus a readiness probe that waits two seconds after start:
yaml
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 2
periodSeconds: 5sh
kubectl get pods -n caverns-x1cyjdThe new Pod shows 0/1 for two seconds, then 1/1, and RESTARTS stays at 0.