Kubernetes Liveness Probes
Step 1: Implement Liveness Probe Health Checks
- The API being a crucial part of the application it needs to be highly available
Step 1.1: Configure the Probe
$ mkdir -p ~/environment/healthchecks
$ cat <<EoF > ~/environment/healthchecks/liveness-app.yaml
apiVersion: v1
kind: Pod
metadata:
name: liveness-app
spec:
containers:
- name: liveness
image: jrdalino/calculator-backend
livenessProbe:
httpGet:
path: /health
port: 5000
initialDelaySeconds: 5
periodSeconds: 5
EoF
Step 1.2: Create the pod using the manifest
$ kubectl apply -f ~/environment/healthchecks/liveness-app.yaml
$ kubectl get pod liveness-app
$ kubectl describe pod liveness-app
Step 1.3: Introduce a Failure to Test
$ kubectl exec -it liveness-app -- /bin/kill -s SIGUSR1 1
$ kubectl get pod liveness-app
$ kubectl logs liveness-app
$ kubectl logs liveness-app --previous
$ kubectl delete -f ~/environment/healthchecks/liveness-app.yaml