Setting up Self-Healing Apps in Kubernetes

1.5 hours
  • 2 Learning Objectives

About this Hands-on Lab

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:

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:

Additional Resources

Your team has built a continuous delivery process for the train schedule app. They are using a Jenkins pipeline to deploy the app to a Kubernetes cluster. However, a few recent deployments have caused problems for the app. App containers are periodically entering an unhealthy state which causes the application to return HTTP 500 errors to users.

The team has asked you to address this problem by implementing some behavior to allow Kubernetes to detect when a container has become unhealthy so the container can be automatically restarted.

To do this, you will need to do the following:

Set up a Jenkins project for the app and deploy it to the Kubernetes cluster:

  • Fork the GitHub source code at
  • 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:

  • Modify the Kubernetes template in your GitHub fork to add a liveness probe.
  • 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.

Note: The train-schedule app includes an endpoint designed to simulate the app becoming unhealthy so that you can trigger an instance of the app to break at will. Once deployed, if you access that endpoint in your browser at <Kubernetes Node Public IP>:8080/break, all future requests to that container will return 500 error codes until it is restarted. You can use this to test self-healing functionality once you have implemented it.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!