javakubernetesstartup-probe

Kubernetes Startup probe when endpoint is not reachable


I have the following deployment config. The test-worker-health and health endpoints are both unreachable as the application is failing due to an error. The startup probe keeps restarting the container after failing as restartPolicy: Always. The pods enter CrashLoopBackoff state. Is there a way to fail such startup probe?

livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: 8080
          periodSeconds: 20
          successThreshold: 1
          timeoutSeconds: 30
startupProbe:
          httpGet:
            path: /test-worker-health
            port: 8080
          failureThreshold: 12
          periodSeconds: 10

Solution

  • The startup probe keeps restarting the container after failing

    The startupProbe does not restart your container, but the livenessProbe does.

    The pods enter CrashLoopBackoff state. Is there a way to fail such startup probe?

    If you remove the livenessProbe, you will not get this restart-behavior. You may want to use a readinessProbe instead?

    Is there a way to fail such startup probe?

    What do you mean? It is already "failing" as you say. You want automatic rollback? That is provided by e.g. Canary Deployment, but is a more advanced topic.