Hello World Example
This Spring Boot application exposes an endpoint that we can call to receive a Hello World message as response. The application is configured using the
@RestController and the method returning the message is annotated with @RequestMapping("/")
The uberjar of the Spring Boot application is packaged within a Docker image using the Fabric8 Maven plugin and next deployed top of the Kubernetes management platform as a pod using the replication controller created by the plugin.
To play with the example, it is required to have access to a Kubernetes Management Platform which is available on GCE. If you don't have an account on GCE,
you can install locally Kubernetes & Docker using [Minikube](https://kubernetes.io/docs/getting-started-guides/minikube/) within a Virtual Machine
managed by a hypervisor (Xhyve, Virtualbox or KVM) if your machine is not a native Unix operating system.
The script to install minikube is
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.17.1/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
When the client is installed on your machine, you can start kubernetes using this command:
minikube start
Next, you can play with this Spring Boot application in the cloud using the following maven command to deploy it:
mvn clean package fabric8:deploy -Pkubernetes
When the application has been deployed, you can access its service or endpoint url using this command:
minikube service kubernetes-hello-world --url
And next you can curl the endpoint using the url returned by the previous command
curl http://IP_OR_HOSTNAME/
Integration test
To deploy the replication controller, create the pod & access its service on Kubernetes, we will use the Arquillian Kubernetes Cube framework. It will use the yaml configuration file generated by the Fabric8 maven plugin in order to talk to the platform toi create the different objects;replication controller, pod, service ... When the service becomes available, the unit test which is a HTTP Client will call the endpoint to verify that it receives as reponse message "Hello World"
To play with the integration test, execute the following maven command:
mvn clean install -Pintegration