pjgg / QuarkusRemoteDevModeDemo

Quarkus RemoteDevMode over Kind (k3s)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RemoteDevMode example over Kind (k3s)

This project is an example of Quarkus remoteDevMode over Kind. Basically Quarkus allows you to update your application code on the fly and do a hot deployment into Kubernetes

Requirement

  • Java17
  • Docker
  • kubectl
  • Kind (K3s)
  • golang
  • Quarkus Cli (Optional)

Install Kind (k3s)

Kind is a single kubernetes node, deployed as a docker instance. To install kind just compile the sources and moves the generated binary to /usr/local/bin

Install Kind commands example

compile kind

go install sigs.k8s.io/kind@v0.18.0

moves the generated bits to /usr/local/bin

mv ~/go/bin/kind /usr/local/bin/kind

double check that is installed: kind --version

In order to know more about how to install kind please take a look the official documentation

Deploy Kind cluster

We are going to deploy our Quarkus app under a service that is exposed through a nodePort so our cluster is going to be listening on port 8080 and pointing to containerPort: 30771 as is described in Kind documentation

    extraPortMappings:
      - containerPort: 30771
        hostPort: 8080
        protocol: TCP

The full kind cluster custom config are located under kind/kind-example-config.yaml

Launch Kind Cluster

kind create cluster --config kind/kind-example-config.yaml

Verify Cluster settings

kubectl cluster-info --context kind-kind

Quarkus required configuration

In order to run / hotDeploy our application into a Kind cluster we will need to deploy Quarkus as a mutable-jar using docker Jib plus some other required configuration, as environment QUARKUS_LAUNCH_DEVMODE=true or quarkus.live-reload.password.

Everything is well explained on the official site.

RemoteDevMode application.properties example:

# Required by remoteDevMode
quarkus.package.type=mutable-jar
quarkus.live-reload.password=changeit
quarkus.jib.environment-variables.QUARKUS_LAUNCH_DEVMODE=true

The rest of the configuration are not remarkable in my opinion

quarkus.container-image.build=true
quarkus.kubernetes.deploy=true
quarkus.kubernetes.namespace=default
quarkus.kubernetes.node-port=30771

We are using the fixed nodePort that we set previously.

Run Quarkus in remoteDevMode

  1. Compile your app gradle clean build

  2. Run your app in remote devMode gradle quarkusRemoteDev -Dquarkus.live-reload.instrumentation=true -Dquarkus.live-reload.url=http://localhost:8080

  3. Verify that you see something like this into your logs

> :qu2023-04-08 17:41:20,974 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 11684ms
<====2023-04-08 17:41:21,319 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending lib/deployment/appmodel.dat
2023-04-08 17:41:21,326 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending app/quarkus-application.jar
2023-04-08 17:41:21,329 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Sending quarkus-run.jar
2023-04-08 17:41:21,330 INFO  [io.qua.ver.htt.dep.dev.HttpRemoteDevClient] (Remote dev client thread) Connected to remote server

Now you can start making changes into your code and will be re-deployed after receive a request.

Demo

QuarkusRemoteDevMoce

Delete kind cluster

kind delete cluster

About

Quarkus RemoteDevMode over Kind (k3s)


Languages

Language:HTML 99.3%Language:Kotlin 0.6%Language:Java 0.1%