Eclipse JKube: Cloud-Native Java Applications Made Easy

Aug 12, 2021 | Programming

Welcome to the world of Eclipse JKube, where deploying Java applications to cloud environments like Kubernetes and OpenShift becomes a breeze! In this article, we’ll walk you through the essential components, usage, and troubleshooting tips for making your applications cloud-native without a hassle.

Introduction

Eclipse JKube is a collection of powerhouse plugins and libraries that simplify the process of building container images with Docker, JIB, or S2I strategies. It simultaneously generates and deploys Kubernetes and OpenShift manifests right at compile time. Think of Eclipse JKube as your personal cloud-native Swiss Army knife, equipped with all necessary tools for transitioning your Java applications to the cloud.

Kubernetes Maven Plugin

This powerful plugin allows Maven users to easily build, push, and deploy their applications to Kubernetes.

Add the plugin to your project by modifying the pom.xml file as follows:

<plugin>
    <groupId>org.eclipse.jkube</groupId>
    <artifactId>kubernetes-maven-plugin</artifactId>
    <version>$jkube.version</version>
</plugin>

To run the JKube commands, execute:

mvn package k8s:build k8s:push k8s:resource k8s:apply

For a quick visual overview, check out the demo on YouTube:

Kubernetes Maven Plugin Demo

Kubernetes Gradle Plugin

For Gradle users, Eclipse JKube offers a similar plugin to make the transition smooth.

Add the plugin in your build.gradle:

plugins {
    id 'org.eclipse.jkube.kubernetes' version '$jKubeVersion'
}

Run the corresponding JKube commands with:

gradle build k8sBuild k8sPush k8sResource k8sApply

And don’t forget to check out the demo:

Kubernetes Gradle Plugin Demo

OpenShift Plugins

Eclipse JKube provides similar plugins for OpenShift, catering to both Maven and Gradle users:

Integrate the OpenShift Gradle Plugin into your project:

plugins {
    id 'org.eclipse.jkube.openshift' version '$jKubeVersion'
}

Use the command:

gradle build ocBuild ocResource ocApply

Watch the demo here:

OpenShift Gradle Plugin Demo

Getting Started

To dive right in, explore the quickstarts in the quickstarts directory featuring sample Maven and Gradle projects using the latest JKube plugin version.

Hello World using Eclipse JKube

Follow these steps to create and run your first application:

  1. Clone the repository:
  2. git clone git@github.com:eclipsejkube.git
  3. Navigate to the Hello World Quickstart folder:
  4. cd jkube/quickstarts/maven/hello-world
  5. Configure your local environment to use the Docker daemon inside Minikube:
  6. eval $(minikube -p minikube docker-env)
  7. Build the project and run JKube goals:
  8. mvn clean install k8s:build k8s:resource k8s:apply
  9. Check the created pod logs using:
  10. kubectl get pods

Troubleshooting

In case you encounter problems such as “ImagePullBackOff”, ensure that you share Minikube’s Docker daemon environment with your shell:

eval $(minikube -p minikube docker-env)

To revert, use:

eval $(minikube docker-env -u)

If you frequently use this command, consider adding it to your .bash_profile or .zshrc.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Rebranding Notice

Eclipse JKube is a rebranded version of the earlier Fabric8 Maven Plugin, redesigned for Java developers working with Kubernetes.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox