Very simple Spring WebMVC framework application to demonstrate Eclipse JKube's capabilities regarding Java Web Applications.
The project is based in Java 11.
In order to run this example you will need a valid K8s cluster accessible via kubectl.
$ mvn clean packageThis will create a deployable war in ./target/example-0.0.0-SNAPSHOT.war
$ mvn k8s:buildThis will create a docker image tagged webapp/example:latest
$ mvn oc:buildThis will create an ImageStream with name example (172.30.39.149:5000/jkube/example:latest)
$ mvn k8s:resourceThis will generate resource manifests in target/classes/META-INF/jkube/kubernetes.yml
$ mvn oc:resourceThis will generate resource manifests in target/classes/META-INF/jkube/openshift.yml
NOTE: If you built your image using Docker, you'll either need to have a shared Docker Daemon
with the cluster (e.g. eval $(minikube docker-env)) or push your image to an accessible
registry first (i.e. mvn k8s:push).
$ mvn k8s:applyA new Deployment will be created with name example
If you built your image using oc:build, your image will already be in the cluster, so
there is no need to push it or have a shared Docker daemon.
$ mvn oc:applyYour web application should now be deployed on the cluster, you can test the endpoint by:
# Minikube
$ curl $(minikube ip):$(kubectl get svc example -n default -o jsonpath='{.spec.ports[].nodePort}')
Hello!!!
# OpenShift
$ curl $(kubectl get routes.route.openshift.io example -o jsonpath='{.spec.host}')
Hello!!!