Skip to content

Commit

Permalink
feat: ✨ Probes: Readiness + Liveness combined
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
kevencript committed Mar 18, 2023
1 parent 444f086 commit 9a8a796
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9a8a796

Please sign in to comment.