Kubernetes

Explain the purpose of the following lines

livenessProbe:
  exec:
    command:
    - cat
    - /appStatus
  initialDelaySeconds: 10
  periodSeconds: 5

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

These lines make use of liveness probe. It's used to restart a container when it reaches a non-desired state.

In this case, if the command cat /appStatus fails, Kubernetes will kill the container and will apply the restart policy. The initialDelaySeconds: 10 means that Kubelet will wait 10 seconds before running the command/probe for the first time. From that point on, it will run it every 5 seconds, as defined with periodSeconds