Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions content/healthchecks/livenessprobe.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Use the command below to create a directory
mkdir ~/environment/healthchecks
```

Save the manifest as liveness-app.yaml using your favorite editor. The livenessProbe definition explains how a simple http health check can be configured for a nodejs application. Any container created from ecsdemo-nodejs application responds to http://:3000/health with a 200 to let the healthcheck pass.
Save the manifest as liveness-app.yaml using your favorite editor. You can review the manifest that is described below. In the configuration file, livenessProbe determines how kubelet should check the Container in order to consider whether it is healthy or not. kubelet uses periodSeconds field to do frequent check on the Container. In this case, kubelet checks liveness probe every 5 seconds. initialDelaySeconds field is to tell the kubelet that it should wait for 5 seconds before doing the first probe. To perform a probe, kubelet sends a HTTP GET request to the server hosting this Pod and if the handler for the servers /health returns a success code, then the Container is considered healthy. If the handler returns a failure code, the kubelet kills the Container and restarts it.

```
apiVersion: v1
Expand All @@ -32,13 +32,13 @@ spec:
periodSeconds: 5
```

Now, we will create a pod to test liveness probe.
Let's create the pod using the manifest

```
kubectl apply -f ~/environment/healthchecks/liveness-app.yaml
```

The above command creates a pod with liveness probe as described in the beginning
The above command creates a pod with liveness probe

```
kubectl get pod liveness-app
Expand Down Expand Up @@ -75,8 +75,7 @@ We will run the next command to send a SIGUSR1 signal to the nodejs application.
kubectl exec -it liveness-app -- /bin/kill -s SIGUSR1 1
```

Describe the pod after waiting for 15-20 seconds and output has a trail as below

Describe the pod after waiting for 15-20 seconds and you will notice kubelet actions of killing the Container and restarting it.
```
Events:
Type Reason Age From Message
Expand Down
13 changes: 2 additions & 11 deletions content/healthchecks/readinessprobe.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ weight: 10

# Configure Readiness Probe

Save the text from following block as ~/environment/healthchecks/readiness-deployment.yaml. The readinessProbe definition explains how a linux command can be configured as healthcheck. We create an empty file /tmp/healthy to configure readiness probe and use the same to understand how kubelet helps to update a deployment with only healthy pods.

Save the text from following block as ~/environment/healthchecks/readiness-deployment.yaml. Readiness probes are defined much similar to liveness probes. The only difference is, you use readinessProbe instead of livenessProbe within your configuration. In the following example, we create an empty file /tmp/healthy and put the container to sleep to keep it alive. Kubelet checks if the file exists to determine if its healthy

```
apiVersion: apps/v1
Expand Down Expand Up @@ -38,13 +37,6 @@ spec:

```

You may also download readiness-deployment.yaml file with the following commands

```
cd ~/environment/healthchecks
wget https://eksworkshop.com/healthchecks/readiness.files/readiness-deployment.yaml
```

We will now create a deployment to test readiness probe

```
Expand All @@ -53,7 +45,6 @@ kubectl apply -f ~/environment/healthchecks/readiness-deployment.yaml

The above command creates a deployment with 3 replicas and readiness probe as described in the beginning


```
kubectl get pods -l app=readiness-deployment
```
Expand All @@ -80,7 +71,7 @@ The output looks like below
Replicas: 3 desired | 3 updated | 3 total | 3 available | 0 unavailable
```

Pick one of the pods from above 3 and issue a command as below to terminate the node process which makes the readiness probe fail.
Pick one of the pods from above 3 and issue a command as below in order to force readiness probe to fail.

```
kubectl exec -it readiness-deployment-<pod> -- rm /tmp/healthy
Expand Down