Using Eclipse JKube to handle your Kubernetes/OpenShift operations

Note: Fabric8 Maven Plugin has been migrated to Eclipse JKube


Eclipse JKube

Eclipse JKube is a set of tools which Java developers can use to build and deploy their applications on Kubernetes/OpenShift. We have two separate plugins for Kubernetes and OpenShift which are focused towards java development on these platforms:

Eclipse JKube Kubernetes and OpenShift Plugins

Since most of the Java developers use maven, it’s really easy to adapt as compared to kubectl or oc command line. This plugin basically does the following tasks:

  • Building Docker images
  • Creating Kubernetes/OpenShift resource(`*.yml`) files
  • Deploying those resources onto Kubernetes/OpenShift

So let’s take a look into these tasks in detail, first you need to have a maven project in order to test Eclipse JKube. You can get some quickstart from, Snowdrop quickstarts or you can use any existing maven project. I would be using this project in this demo:

Getting the Plugin:

Eclipse JKube is available on Maven Central. You need to add this in your plugins section of your pom:

Eclipse JKube Kubernetes and OpenShift Plugins

Setting up your local Kubernetes/OpenShift cluster:

To develop on Kubernetes, you need a kubernetes cluster; just like you need an instance of application server to deploy your application. If you already have access to a Kubernetes cluster, then you’re good to go. You should be able to connect to it using kubectl. Otherwise you can install minikube (which implements a local Kubernetes cluster on your machine). Or if you want to setup an OpenShift cluster, you should install minishift.

Building Project:

Eclipse JKube includes allows you to build docker images of your applications with ease. In order to make docker image of your project, you just need to run command:

mvn k8s:build

Kubernetes Maven Plugin Build Goal

Generating Kubernetes/OpenShift artifacts:

Eclipse JKube generates resource descriptors for both Kubernetes and OpenShift. In order to generate Kubernetes/Openshift artifacts, just run the resource goal:

mvn k8s:resource

Kubernetes Maven Plugin resource goal

If you check your target directory you can see the generated artifacts in target/classes/META-INF/jkube/ directory

Generated resources

Deploying Your application onto Kubernetes/Openshift:

Well deploying your application is just about applying those generates resources onto the cluster. You just need to do:

mvn k8s:apply

Kubernetes Maven Plugin Apply goal

Once your application is deployed, you can check generated service and access it. I had added a property in my pom that told Fabric8 Maven Plugin to generate a Service of type NodePort.

Configuring Eclipse JKube to generate NodePort Service

I accessed it like this:

Accessing Application running inside Kubernetes(minikube)

Configuration Options:

The above was an example of zero configuration; In case you want to customize generated resources you can do it via:

  • Plugin XML configuration
  • external resource fragments
  • Dockerfiles

I’ll explain in more detail about these configuration options in a separate blog. For more information, please check out plugin’s website. If you want to checkout some demo, please checkout this asciicasts:

Try Eclipse JKube on Katakoda:

Want to get started fast, we have provided a quick Katakoda scenario for you get a quick look at our plugins:

You can also take a look at a demo YouTube video for the project in which we deploy a simple spring-boot application onto Kubernetes:

Migrating from Fabric8 Maven Plugin to Eclipse JKube:

Are you already using Fabric8 maven Plugin and want to switch to Eclipse JKube. You might want to check out our docs on how to migrate your project to Eclipse JKube: Eclipse JKube Migration Guide

Providing Feedback:

We love to hear from users about how they feel about the project and if they want to get some enhancement into project. If you like Eclipse JKube please support us by either 🌟 on Github or by spreading word about it. Please reach out to us either via Github issues, or our Gitter Channel. You can also follow us on Twitter at @jkubeio twitter handle.