Containerize your Java Applications using Eclipse JKube
Marc Nuri
About me
Marc Nuri
Senior Software Engineer - Red Hat
Working on:
Fabric8 Kubernetes Client
Eclipse JKube
@MarcNuri
MarcNuri
manusa
Agenda
Introduction
Deploying applications to Kubernetes - Challenges
What is Eclipse JKube?
Demo
Why should I choose Eclipse JKube?
Introduction
Code
Build
Fat Jar / War / Ear
JRE
OS
Deploy
Server
JRE
OS
Kubernetes
Deploying applications to Kubernetes - Challenges
Dockerfile
FROM openjdk:8-jdk-alpine EXPOSE 8080 ARG JAR_FILE=target/*.jar USER 1000:1000 COPY ${JAR_FILE} /deployments/app.jar ENV JAVA_OPTIONS="-Xmx2G" ENTRYPOINT ["java","-jar","/deployments/app.jar"]
$ mvn package $ docker build -t user/app:tag ./ $ docker login $ docker push user/app:tag
YAML files
kind: Deployment metadata: name: app spec: replicas: 1 selector: # ...
kind: Service metadata: name: app spec: ports: # ...
kind: ConfigMap metadata: name: app data: application.yml: >- # ...
$ kubectl apply -f ./your-yaml.yml
What is Eclipse JKube?
Tools and plugins
Generate container images
Generate and deploy configuration manifests (Kubernetes / OpenShift)
Standalone Java API (Kit) & Maven Plugins
Kubernetes Maven Plugin (k8s)
OpenShift Maven Plugin (oc)
Build Strategies
Docker:
uses local Docker Daemon (k8s) or remote (oc)
S2I:
OC only plugin configuration
JIB:
delegates to build to JIB (Dockerless)
What is Eclipse JKube? (2)
Support for multiple frameworks and technologies
3 configuration modes
Zero Config
, Opinionated defaults
Project Analysis and cluster detection
Inferred image configuration
Inferred cluster manifests
XML
plugin configuration
Resource fragments
enrich missing parts of opinionated defaults
What is Eclipse JKube? (3)
<plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>kubernetes-maven-plugin</artifactId> <version>1.1.0</version> </plugin>
$ mvn package k8s:build k8s:push k8s:resource k8s:apply # Or even better $ mvn package k8s:deploy
JKube vs. Dockerfile + YAML
Demo
Why should I choose Eclipse JKube?
Covers complete Workflow (from code to Kubernetes)
No external dependencies
The Java way
Zero Configuration
Additional tools for Developers (Debug, Watch, etc.)
Thank you!
github.com/eclipse/jkube
@jkubeio
www.eclipse.org/jkube