This Red Hat Fuse booster demonstrates how to use the Kubernetes health check to determine whether a container is alive and ready to serve the traffic for the HTTP endpoints of an application.
The Health Check booster configures a /health
HTTP endpoint that Kubernetes uses to issue HTTP requests. If the container is alive then the Health HTTP endpoint returns HTTP code 200 as a response and Kubernetes takes no further action. If the HTTP endpoint stops returning a 200 response, Kubernetes restarts the container pod.
You can run this booster in the following modes:
-
Single-node OpenShift cluster
-
OpenShift Online at https://developers.redhat.com/launch
-
Standalone on your machine (although this mode does not include an automatic mechanism to restart your application when it stops)
The most effective way to use this booster is to deploy and run the project on OpenShift.
For more details about running this booster on a single-node OpenShift cluster, CI/CD deployments, as well as the rest of the runtime, see the Spring Boot Runtime Guide.
Important
|
This booster requires Java 8 JDK or later and Maven 3.3.x or later. |
A single-node OpenShift cluster provides you with access to a cloud environment that is similar to a production environment.
If you have a single-node OpenShift cluster, such as Minishift or the Red Hat Container Development Kit, installed and running, you can deploy your booster there.
To deploy this booster to a running single-node OpenShift cluster:
-
Download the project and extract the archive on your local filesystem, for example to a folder called
my_openshift
. -
Log in to your OpenShift cluster:
$ oc login -u developer -p developer
-
Create a new OpenShift project for the booster:
$ oc new-project MY_PROJECT_NAME
-
Change the directory to the folder that contains the extracted booster application (for example,
my_openshift/fuse-health-check-booster
):$ cd my_openshift/fuse-health-check-booster
-
Build and deploy the project to the OpenShift cluster:
$ mvn clean -DskipTests fabric8:deploy -Popenshift
-
In your browser, navigate to the
MY_PROJECT_NAME
project in the OpenShift console. Wait until you can see that the pod for thefuse-health-check-booster
application has started. -
On the project’s
Overview
page, locate the URL for thefuse-health-check-booster
application. The URL uses this form:http://fuse-health-check-booster-MY_PROJECT_NAME.OPENSHIFT_IP_ADDR.nip.io
. -
Click the URL to access the greetings service application and follow the instructions on that page.
To deploy this booster directly to OpenShift Online when you create the project at https://developers.redhat.com/launch:
-
At the Deployment step, select Use OpenShift Online.
-
Follow the on-screen instructions to create a new Health Check project by using the Fuse runtime.
Note
|
As part of the process of creating this booster, https://developers.redhat.com/launch sets up a project with a CI/CD deployment of this booster. You can see the status of this deployment in your single-node OpenShift cluster or OpenShift Online web console. |
Important
|
When running the booster in this mode, since it is not running in a managed container platform, the application does not automatically restart when it stops. The most effective way to use this booster is to deploy and run the project on OpenShift. |
To run this booster as a standalone project on your local machine:
-
Download the project and extract the archive on your local filesystem.
-
Build the project:
$ cd PROJECT_DIR $ mvn clean package
-
Run the services:
$ mvn spring-boot:run
-
Go to http://localhost:8080 and then follow the instructions on that page.