Java Demo Application for Kubernetes.
The demo runs on HTTP port 8080, and provides the current system environment variables formatted as an ASCII table:
This is useful for exploring the environment of a Kubernetes pod. For example, the HOSTNAME
variable tells which pod is serving the request.
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
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 locally:
View http://localhost:8080.
Test on Kubernetes:
- Get the service's Cluster IP:
export DEMO_SERVICE_IP=$(kubectl get service java-demo -o=jsonpath='{.spec.clusterIP}')
- Access the pods through the service's Cluster IP:
curl $DEMO_SERVICE_IP
You see a compile error in Intellij Idea? Me too, filed this bug report https://youtrack.jetbrains.com/issue/IDEA-203791.