A demo to show how sync local Quarkus sources with pod running in kubernetes and use the quarkus:dev
mode to hot reload the changes.
The demo uses ksync to synchronize the local sources with remote.
Clone the demo sources locally and lets call cloned folder as $PROJECT_HOME
git clone https://github.com/redhat-developer-demos/quarkus-sync-demo.git
./start-minikube.sh
In a new terminal start the ksync watch
to start monitoring changes to local folder.
ksync watch &
Open a new terminal and navigate to $PROJECT_HOME
,
Deploy the demo application:
kubectl apply -f src/main/k8s/app.yaml
The command creates the following resources:
-
a kubernetes deployment called quarkus-sync-demo
-
a kubernetes service called quarkus-sync-demo
-
a persistence volume claim called
m2-cache
to cache the maven artifacts for faster builds
Check the stats of the application:
kubectl get pods -w ##(1)
-
A successful start will have quarkus-sync-demo in Running status
Note
|
|
Once in the running status you can watch the log of the application using:
kubectl logs -f <quarkus-pod-name>
During the initial run you will not see any Quarkus logs as the local and remote sources have not been synched. Tailing logs of pod will show message like Waiting to synchronize project sources
Create a ksync spec that starts the local to remote file synching:
ksync create --name='quarkus-sync-demo'
--reload=false \##(1)
--selector=app=quarkus-sync-demo \
`pwd` /project
Once you set up you sync spec, you should see the quarkus-sync-demo pod will start to run the Quarkus application in dev mode i.e. mvn compile quarkus:dev
Important
|
|
You can check the status of the sync via
ksync get
Lets see the sync in action, open a new terminal and navigate to $PROJECT_HOME
. Run the following command:
./poll.sh ##(1)
-
this will keep calling the kubernetes service once in every 5 seconds
Without any change you should be seeing response as hello
getting printed every 5 seconds.
You can now make changes to the sources e.g change hello
in GreetingResource.java to namaste
After few seconds you will see your polling window sending the new response namaste