Skip to content

redhat-developer-demos/quarkus-sync-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quarkus Kubernetes Sync

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.

Pre-requiste

The demo uses ksync to synchronize the local sources with remote.

Running the demo

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)
  1. A successful start will have quarkus-sync-demo in Running status

Note
  • You can terminate the kubectl get pods -w using the command CTRL+C

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
  1. Since quarkus:dev mode will automatically recompile and reload, its not required to reload the container

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)
  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

Cleanup

kubectl delete -f $PROJECT_HOME/src/main/k8s/app.yaml
ksync delete quarkus-async-demo

Finally stop the ksync watch

About

A demo show how to make quarkus dev mode work with kubernetes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published