Files
Salaboy 1e71319f9f initial Spring Boot 2.0.x refactoring (#152)
* updating discovery and config modules, removing netflix modules to start simple

* hacking some jackson dependencies as they were not working

* update Discovery AutoConfiguration, still messy, more work needed here

* getting configuration working with the service registry

* removing profiles check document matcher that doesn't exist anymore

* fixing configMaps example

* improving readmes and removing arquillian due it requires undertow

* re adding all netflix modules

* re adding commented example modules

* fixing minor naming issues and adding commented out modules
2018-03-16 15:58:24 -04:00

2.4 KiB

Setting up the Environment

To play with these examples, 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.

When the minikube is installed on your machine, you can start kubernetes using this command:

minikube start

You also probably want to configure your docker client to point the minikube docker deamon with:

eval $(minikube docker-env)

This will make sure that the docker images that you build are available to the minikube environment.

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.

Once you have the environment set up (minikube or kubectl configured against a kubernetes cluster)

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

Note: Unfortuntaly, when you deploy using the fabric8 plugin, the readyness and liveness probes fail to point to the right actuator URL due a lack of support for spring boot. This push you to edit the generated deployment inside kubernetes and change these probes which points to "path": "/health" to "path": "/actuator/health". This will make your deployment go green. This issue is already reported into the fabric8 community: https://github.com/fabric8io/fabric8-maven-plugin/issues/1178

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/

then

curl http://IP_OR_HOSTNAME/services

Should return you the list of available services discovered by the DiscoveryClient

mvn clean install -Pintegration