Kubernetes Startup probe when endpoint is not reachable

1.8k Views Asked by At

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
2

There are 2 best solutions below

6
Jonas On BEST ANSWER

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.

0
Oladapo Ajala On

According to your configuration, the startupProbe is tried within 120seconds after which it fails if it doesn't succeed atleast once during that period.

If your application requires more time to start up .i.e > 120seconds, then the startupProbe would keep restarting your application before it's booted up completely.

I'd suggest increasing the failureThreshold to afford your application sufficient time to boot-up.