Skip to content

fstab/java-demo

Repository files navigation

Java Demo Application

Java Demo Application for Kubernetes.

Overview

The demo runs on HTTP port 8080, and provides the current system environment variables formatted as an ASCII table:

Screen Shot

This is useful for exploring the environment of a Kubernetes pod. For example, the HOSTNAME variable tells which pod is serving the request.

Run

A pre-built Docker image is available on fstab/java-demo. Test locally:

docker run -p8080:8080 --rm fstab/java-demo

Deploy on Kubernetes

curl -LO https://raw.githubusercontent.com/fstab/java-demo/master/java-demo.yaml
kubectl create -f java-demo.yaml

Build

This demo requires Java 11.

Option 1: Build the Docker image manually:

mvn package
docker build -t fstab/java-demo .

Option 2: Build using the Docker maven plugin:

mvn package docker:build

Test

Test locally:

View http://localhost:8080.

Test on Kubernetes:

  1. Get the service's Cluster IP:
    export DEMO_SERVICE_IP=$(kubectl get service java-demo -o=jsonpath='{.spec.clusterIP}')
  2. Access the pods through the service's Cluster IP:
    curl $DEMO_SERVICE_IP

Notes

You see a compile error in Intellij Idea? Me too, filed this bug report https://youtrack.jetbrains.com/issue/IDEA-203791.

About

Java Demo Application for Kubernetes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published