Deploy IBM OpenLiberty apps onto Kubernetes using Eclipse JKube

Eclipse JKube deploying OpenLiberty app into Kubernetes

What is OpenLiberty?

Setting up Kubernetes:

minikube start
# To point your shell to minikube's docker-daemon, run:
eval $(minikube -p minikube docker-env)

Getting OpenLiberty Quickstart Guide:

git clone https://github.com/OpenLiberty/guide-getting-started.git
cd guide-getting-started/finish
mvn clean install

Deploying to Kubernetes:

<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>1.0.0-rc-1</version>
</plugin>

Containerizing the application into a Docker image:

Modifying project files’ relative path in Dockerfile and exposing ports
finish : $ mvn k8s:build
[INFO] Scanning for projects...
[INFO]
[INFO] -----< io.openliberty.guides:guide-getting-started >-----
[INFO] Building guide-getting-started 1.0-SNAPSHOT
[INFO] --------------[ war ]---------------------------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:build (default-cli) @ guide-getting-started ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[INFO] k8s: [guides/guide-getting-started:latest]: Created docker-build.tar in 10 seconds
[INFO] k8s: [guides/guide-getting-started:latest]: Built image sha256:424e8
[INFO] k8s: [guides/guide-getting-started:latest]: Removed old image sha256:ad954
[INFO] --------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------------------
[INFO] Total time: 01:35 min
[INFO] Finished at: 2020-08-22T19:46:23+05:30
[INFO] --------------------------------------------------------------------
finish : $ docker images | grep guide-getting-started
guides/guide-getting-started latest 424e87972dcb 6 min ago 741MB

Generating and applying Kubernetes manifests:

<jkube.enricher.jkube-service.port>9080</jkube.enricher.jkube-service.port>
<jkube.enricher.jkube-service.type>NodePort</jkube.enricher.jkube-service.type>
finish : $ mvn k8s:resource k8s:apply
[INFO] Scanning for projects...
[INFO]
[INFO] ------< io.openliberty.guides:guide-getting-started >--------
[INFO] Building guide-getting-started 1.0-SNAPSHOT
[INFO] ----------------------[ war ]-------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:resource (default-cli) @ guide-getting-started ---
[INFO] k8s: jkube-controller: Adding a default Deployment
[INFO] k8s: jkube-service: Adding a default service 'guide-getting-started' with ports [9080]
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[INFO] k8s: validating /home/rohaan/work/repos/openliberty-guide-getting-started/finish/target/classes/META-INF/jkube/kubernetes/guide-getting-started-service.yml resource
[INFO] k8s: validating /home/rohaan/work/repos/openliberty-guide-getting-started/finish/target/classes/META-INF/jkube/kubernetes/guide-getting-started-deployment.yml resource
[INFO]
[INFO] --- kubernetes-maven-plugin:1.0.0-rc-1:apply (default-cli) @ guide-getting-started ---
[INFO] k8s: Using Kubernetes at https://192.168.39.71:8443/ in namespace default with manifest /home/rohaan/work/repos/openliberty-guide-getting-started/finish/target/classes/META-INF/jkube/kubernetes.yml
[INFO] k8s: Using namespace: default
[INFO] k8s: Creating a Service from kubernetes.yml namespace default name guide-getting-started
[INFO] k8s: Created Service: target/jkube/applyJson/default/service-guide-getting-started-1.json
[INFO] k8s: Creating a Deployment from kubernetes.yml namespace default name guide-getting-started
[INFO] k8s: Created Deployment: target/jkube/applyJson/default/deployment-guide-getting-started-1.json
[INFO] k8s: HINT: Use the command `kubectl get pods -w` to watch your pods start up
[INFO] --------------------------------------------------------------------[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------------------[INFO] Total time: 8.726 s
[INFO] Finished at: 2020-08-22T20:02:47+05:30
[INFO] --------------------------------------------------------------------
finish : $

Checking deployed application running in Kubernetes:

Checking application pods running in Kubernetes after jkube deploy
finish : $ minikube service guide-getting-started|-----------|-------------|-------------|--------------------------|
| NAMESPACE | NAME| TARGET PORT | URL | |-----------|-------------|-------------|--------------------------|
| default | guide-getting-started | glrpc/9080 | http://192.168.39.71:31104 |
|-----------|---------------|-------------|------------------------|
🎉 Opening service default/guide-getting-started in default browser...
OpenLiberty Geting started sample running inside minikube(output of minikube service)
mvn k8s:log
mvn k8s:undeploy

--

--

--

https://about.me/rohankanojia

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS RDS Pricing and Optimization Guide

What Ruby taught me

Taraxa Community Update — November 2020.

The casual stroll to the bathroom feels like the walk of shame in

Dijkstra Algorithm

Rust Code Reading Club

Push Notifications: Firebase Vs. OneSignal

The Road of Tiny Habits that lead to Code-topia

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rohan Kumar

Rohan Kumar

https://about.me/rohankanojia

More from Medium

Installation of Kubernetes with Kubespray

Kubernetes — Quick guide

What is making your Docker image bloat?

Setting custom headers using Ingress with Helm Chart