Looking for an Expert Development Team? Take two weeks Trial! Try Now or Call: +91.9824127020

Spring Boot Microservices in Kubernetes


Spring cloud Kuberntes is one of the child projects of Spring Cloud. It mainly focuses on deploying the Spring boot Microservices in Kubernetes Environment, and how to access other Kubernetes Services in Microservices.

For those who don’t know about Kubernetes: Kubernetes is one of the tools for Container Orchestration, which used for automating deployment, scaling and management of the containerized applications.

Kubernetes is not specific not any containerized tools, it supportsall majorly used tools like Docker, rkt (Rocket Container), based on configuration settings.

Spring Cloud Kubernetes will be replacement for many of the Spring cloud child projects, like Spring Cloud Config, Spring Cloud Eureka, Spring Cloud Zuul, instead of these frameworks we can use Service Registry, configMaps, Secret, ingress provided by Kubernetes.

Ingress is one of the components in Kubernetes is route the traffic based on path to specified Microservices Development Services in configuration.


Although Spring Cloud Kubernetes is sub-project of Spring cloud, but it is not released under Spring Cloud Releases, we need to add the Kubernetes dependency similar to other dependencies not like Spring Cloud dependency.

Project Setup:

Apart from Spring boot web starter dependency, we need to add the below dependencies.


Here, we included Spring Boot Actuator in our project dependency, the Actuator endpoint are used to provide in Kubernetes configuration in livenessProbe, and readnessProbe.


"livenessProbe": {
                                "httpGet": {
                                "path": "/actuator/health",
                                "port": 8080,
                                "scheme": "HTTP"
                                "readinessProbe": {
                                "httpGet": {
                                "path": "/actuator/health",
                                "port": 8080,
                                "scheme": "HTTP"


We need at least single node cluster of running Kubernetes instance on machine.

Spring Cloud Kubernetes will access Kubernetes Rest API to get the information about cluster, services, deployments etc. Spring Cloud Kubernetes will try to get the Kubernetes components using defaultserviceaccount. As Kubernetes provides default role, we need to bind this role to cluser admin role.


For binding either we can use attached json file, and execute the kubectl apply -f

Or we can execute the below command

kubectl create clusterrolebinding admin –clusterrole=cluster-admin –serviceaccount=default:default

Maven Plugin Configuration:

Fabric8 is one of most used maven plugin for building Kubernetes resource json files, and creating docker images, pushing the docker images to Docker registry, and also deploying/undeploying the application docker images to Kubernetes cluster.

And provide the watch goal is to monitor for changes during the development and auto update the docker image in cluster.

log is the to display the logs of the application in cluster.

And it provides the helm(Packaging tool for Kubernetes) integration to create helm package.

It also provide the way to debug the application which is running in Kubernetes cluster using debuggoal.

mvn fabric8:debug -Dfabric8.debug.port=8000

Sample Maven Configuration for Fabric8 Plugin:

<!-- goal>push</goal -->

authConfig will contains the authentication information for contacting the public docker repository, for pulling and pushing the images into it.

Machine is the will contains the information about docker machine, used to build the docker images.

If the docker machine is not present, we can use autoCreate tag to create new one, using docker-machine.exe, which is provided by docker, we can download the same from docker website and add to PATH variable.

Note: for this work, we need to install VirtualBox, to create docker virtual machine.

fabric8:deploy will generate the Kubernetes component JSON files in targt/classes/META-INF/fabric8 folder.


And we can see the below line in console.


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

fabric8:push will push the docker image to docker hub.


Note: while doing the push, make sure that groupId has the docker hub username.

Application setup:

@EnableDiscoveryClientis one of the annotations to enable the discovery of the services.

DiscoveryClient is the class which hold the information about services.


Spring Cloud Kubernetes is the library to deploy, and consume the resources on Kubernetes environment, Fabric is the maven plugin for all related tasks, like building the image, push into docker hub, and deploying into Kubernetes environment.

Source code can be download at https://github.com/sravan4rmhyd/Hello-world-Kubernetes.git

Post Tags

#kubernetes  #spring cloud

Aegis Infoways

Aegis Infoways is a leading software development company that provides a wide range of business solutions like software development, data warehouse, or web development for specific business needs.

Related Posts

CompletableFuture in Java

CompletableFuture in Java

Technology CompletableFuture is used for asynchronous programming in Java. Asynchronous Programming means running tasks in a separate thread, other than the main thread, and notifying the execution progress like completion or failure. It helps improve application...

Best Practices Things That Help Ms CRM Develo...

Best Practices Things That Help Ms CRM Develo...

It is always the clever MS CRM developers who think about configuration first before customization. Although Dynamics CRM offers many things, such as flexibility and customization, developers need to be more careful about customizing CRM objects. Smarter developers...

10 Eclipse Java Plug-ins You Can’t Do Witho...

10 Eclipse Java Plug-ins You Can’t Do Witho...

Eclipse is the most widely used integrated development environment for Java. Used to develop the Java applications, Eclipse is also often used to develop applications. Its extensive plug-ins give it the flexibility to be customized. This open-source software has...