Fix the probe configuration that keeps restarting a slow-starting Java app.
IntermediateHands-onWrite-a-Kubernetes-manifest tasks
Answer
Broken:
livenessProbe:
httpGet: { path: /actuator/health, port: 8080 }
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
Fixed:
startupProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 5
failureThreshold: 30 # up to 150s to start
livenessProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }
periodSeconds: 5
Key trick → The app needed about 60s to start, but liveness killed it after 20s, causing a CrashLoopBackOff. A startupProbe holds off liveness until the first success.
More on Write-a-Kubernetes-manifest tasks
Write a Deployment and Service for an Nginx app with 3 replicas, resources and probes.BeginnerAdd an HPA that scales the Deployment between 3 and 15 pods at 70% CPU.BeginnerFix this broken Deployment YAML.BeginnerWrite a ConfigMap and Secret and inject them as environment variables and as a mounted file.IntermediateWrite an Ingress that routes `/api` to the api service and `/` to the web service with TLS.IntermediateWrite a pod spec with a hardened securityContext.Intermediate