Kubernetes includes powerful features for building self-healing application clusters. By default, if the application running in a container crashes completely, Kubernetes will automatically restart the container. However, application health can be more complicated than simply whether or not an application process is still running. This activity will guide you through the process of building more sophisticated problem detection for an app running on Kubernetes. That will allow you to strengthen the self-healing capabilities of your application infrastructure on Kubernetes.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Set up a Jenkins Project for the App and Deploy It to the Kubernetes Cluster
To do this, you will need to do the following:
- Fork the GitHub source code at https://github.com/linuxacademy/cicd-pipeline-train-schedule-selfhealing.
- Set up credentials in Jenkins for GitHub, Docker Hub, and the Kubernetes cluster.
- Create a project to build from your GitHub fork, run a build, and approve production deployment to deploy the app to the cluster.
- Create and Deploy a Liveness Probe to Detect Error Responses from the App and Restart Unhealthy Containers
To do this, you will need to do the following:
- Modify the Kubernetes template in your GitHub fork to add a liveness probe.
livenessProbe: httpGet: path: / port: 8080 initialDelaySeconds: 15 timeoutSeconds: 1 periodSeconds: 10
Check the example-solution branch of the GitHub repo for an example of how this code can be used: https://github.com/linuxacademy/cicd-pipeline-train-schedule-selfhealing/blob/example-solution/train-schedule-kube.yml.
- Deploy the application again by running a build and approving the deployment.
- Test the probe by breaking the app and watching Kubernetes automatically restart the container.
- Modify the Kubernetes template in your GitHub fork to add a liveness probe.