0

I'm using kubernetes with helm. My github pipeline contains:

  - name: Verify deployment
    run: kubectl rollout status deployment/name-api --namespace my-prod --timeout=60s

Sometime this part fails with:

Readiness probe failed: Get “https://...:80/”: dial tcp ...:80: connect: connection refused

When I then re-run the Action, it often passes.
What should I do against this?

I've already tried adding the last line below in deployment.yaml in the templates folder, based on the answer at https://stackoverflow.com/a/51932875. But that didn't help.

spec:
  template:
    spec:
      containers:
        - name: {{ .Chart.Name }}
          …
          readinessProbe:
            initialDelaySeconds: 5
Marty
  • 2,132
  • 4
  • 21
  • 47

1 Answers1

0

Maybe you need a startup probe?

Sometimes, you have to deal with legacy applications that might require an additional startup time on their first initialization. In such cases, it can be tricky to set up liveness probe parameters without compromising the fast response to deadlocks that motivated such a probe. The trick is to set up a startup probe with the same command, HTTP or TCP check, with a failureThreshold * periodSeconds long enough to cover the worse case startup time.

Example:

ports:
- name: liveness-port
  containerPort: 8080
  hostPort: 8080

livenessProbe:
  httpGet:
    path: /healthz
    port: liveness-port
  failureThreshold: 1
  periodSeconds: 10

startupProbe:
  httpGet:
    path: /healthz
    port: liveness-port
  failureThreshold: 30
  periodSeconds: 10

Thanks to the startup probe, the application will have a maximum of 5 minutes (30 * 10 = 300s) to finish its startup. Once the startup probe has succeeded once, the liveness probe takes over to provide a fast response to container deadlocks. If the startup probe never succeeds, the container is killed after 300s and subject to the pod's restartPolicy

Source: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes

lbrandao
  • 4,144
  • 4
  • 35
  • 43