kameshsampath / jo

Jo - Java way to do Ko
GNU General Public License v3.0
5 stars 1 forks source link
java jbang jitpack jkube quarkusio

= Jo

Highly inspired from https://github.com/google/ko[ko], a similar tool for deploying any Java microservices (uber jars) as Kubernetes application

IMPORTANT: Under active development so lots change and at times breaking :D

== Pre-requisites

NOTE: If you are using Docker for Windows, then https://docs.microsoft.com/en-us/windows/wsl/install-win10[Windows subsytem for Linux (WSL)] is recommended.

== Build jo

[source,bash]

git clone https://github.com/kameshsampath/jo cd jo export $PROJECT_HOME=pwd ./mvnw clean install -DskipTests

== Start Kubernetes Cluster

IMPORTANT: Currently the application is tested only with local clusters. Working on to add support to hosted clusters

[source,bash]

$PROJECT_HOME/bin/start-kind.sh

== Kubernetes Example

=== Jbang

[source,bash]

cd $PROJECT_HOME java -jar target/jo-runner.jar apply --file="$PWD/examples/kubernetes/deployment-jbang.yaml"

The command above should do the deployment of the jbang script github.com/kameshsampath/jo/examples/http/server.java as Kubernetes application.

=== Quarkus

//TODO #10 Handle non uber jar Quarkus projects [IMPORTANT]

Since quarkus does not do uberjar by default, you need to configure Quarkus app to build uberjar so that the runner jar is deployed with classifier: [source,xml]

io.quarkus quarkus-maven-plugin ${quarkus-plugin.version} build true

====

[source,bash]

cd $PROJECT_HOME java -jar target/jo-runner.jar apply --file="$PWD/examples/kubernetes/deployment-quarkus.yaml"

The command above should do the deployment of the Quarkus Applicationt github.com/kameshsampath/jo-quarkus-helloworld as Kubernetes application.

=== SpringBoot

[source,bash]

cd $PROJECT_HOME java -jar target/jo-runner.jar apply --file="$PWD/examples/kubernetes/deployment-spring-boot.yaml"

The command above should do the deployment of the Quarkus Applicationt github.com/kameshsampath/jo-sb-helloworld as Kubernetes application.

Wait for the hello-world pod to come up:

[source,bash]

watch kubectl get pods

Once the pods is up try creating the Service and Ingress to access it:

[source,bash]

cd $PROJECT_HOME kubectl apply --filename="$PROJECT_HOME/examples/kubernetes/service.yaml"

Now doing curl localhost/greeting should show a response like Hello World or Hello from Quarkus or Hello from SpringBoot

== Knative Example

=== Jbang

[source,bash]

cd $PROJECT_HOME java -jar target/jo-runner.jar apply --file="$PWD/examples/knative/service-jbang.yaml"

The command above should do the Knative service deployment of the jbang script github.com/kameshsampath/jo/examples/http/server.java as Kubernetes application.

=== Quarkus

[source,bash]

cd $PROJECT_HOME java -jar target/jo-runner.jar apply --file="$PWD/examples/knative/service-quarkus.yaml"

The command above should do the Knative service deployment of the Quarkus Application github.com/kameshsampath/jo-quarkus-helloworld as Kubernetes application.

=== SpringBoot

[source,bash]

cd $PROJECT_HOME java -jar target/jo-runner.jar apply --file="$PWD/examples/knative/service-spring-boot.yaml"

The command above should do the Knative service deployment of the Quarkus Applicationt github.com/kameshsampath/jo-sb-helloworld as Kubernetes application.

Wait for the greeter Knative service to come up:

[source,bash]

watch kubectl get pods

Once Knative service is up access the service using:

[source,bash]

SVC_URL=$(kubectl get ksvc greeter -ojsonpath="{.status.url}")

the curl will return an Hello World response

curl $SVC_URL

The curl $SVC_URL should show a response like Hello World or Hello from Quarkus or Hello from SpringBoot

== Powered by