From 9a8a79600b10c0aa11d532a61b67c5e1e36d0a75 Mon Sep 17 00:00:00 2001 From: kevencript Date: Sat, 18 Mar 2023 01:11:49 -0300 Subject: [PATCH] feat: :sparkles: Probes: Readiness + Liveness combined The first point that we must to consider when working with both readiness and liveness is that Readiness will STOP the network to the pod as it is not ready (stuck in 0/1 ready) if it fails and Liveness will RESTART the pod when the healthcheck return fail. For this reason, we must to take care about the period in which Readiness take to start the container and make it ready before Liveness start to check it, because it can start a loop of liveness restarting the pod before it is acctually ready (readiness do this step) --- k8s/deployment.yaml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 8b71ec6..552cf42 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -18,24 +18,26 @@ spec: containers: - name: go-http-app image: wesleywillians/hello-go:v5.4 # Probe on port /healthz (+ readiness check: if app is up < 10s it will fail. This way, readiness will only be "ready" when the pod is healthy) - # livenessProbe: - # httpGet: # HTTP strategy (or container command or tcp connection) - # path: /healthz # Created on Go server (docker image) - # port: 8000 # Should be the CONTAINER port - # periodSeconds: 5 # Liveness check frequecy - # failureThreshold: 1 # How many times must to fail until be consider as failed - # timeoutSeconds: 1 # How long the liveness req can wait untill timeout - # successThreshold: 1 # How many times must to success until be consider as health - readinessProbe: + httpGet: + path: /healthz + port: 8000 # Should be the CONTAINER port + periodSeconds: 3 + failureThreshold: 1 + timeoutSeconds: 1 + successThreshold: 1 + initialDelaySeconds: 8 # How much time it will wait untill start to check (In our example, the app takes 10s to start) + + livenessProbe: httpGet: # HTTP strategy (or container command or tcp connection) path: /healthz # Created on Go server (docker image) port: 8000 # Should be the CONTAINER port - periodSeconds: 3 # Readiness check frequecy - failureThreshold: 1 # How many times must to fail until be consider as failed + periodSeconds: 5 # Liveness check frequecy + failureThreshold: 2 # How many times must to fail until be consider as failed timeoutSeconds: 1 # How long the liveness req can wait untill timeout successThreshold: 1 # How many times must to success until be consider as health - initialDelaySeconds: 8 # How much time it will wait untill start to check (In our example, the app takes 10s to start) + initialDelaySeconds: 8 + envFrom: - configMapRef: