Giter VIP home page Giter VIP logo

kameshsampath / skaffold-quarkus-helloworld Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 5.0 28 KB

A demo to show how to use https://https://skaffold.dev with https://quarkus.io developer mode to enable rapid Java application with Kubernetes.

License: Apache License 2.0

Batchfile 5.33% Shell 4.32% Java 17.68% HTML 72.67%
java kubernetes demos developer-mode minikube skaffold skaffold-example quarkus

skaffold-quarkus-helloworld's Introduction

Skaffold Quarkus Hello World

A demo to show how to use Skaffold to do rapid application development with Quarkus.

Pre-requisites

Setup Kubernetes Cluster

minikube profile quarkus-demos
minikube start -p quarkus-demos --memory=8192 --cpus=4 --disk-size=50g #(1)
eval $(minikube docker-env) #(2)
  1. Please add the other needed options as per your operating system

  2. Make the current docker context to be that of minikube

Setup Nexus(Optional)

We will use nexus for caching maven artifacts so that builds are faster.

kubectl apply -f k8s/nexus.yaml

Wait for some time to have nexus initialize and run. You can watch the status via kubectl get pods -w, use Ctrl+c to terminate the watch

Run Skaffold

Important

In both development and production mode, the container image will not be pushed to remote container registry.

Quarkus Development mode

skaffold dev --file skaffold-dev.yaml --port-forward #(1)
  1. Run skaffold in dev mode. The port-forward option automatically forward the Kubernetes service port(default is 8080) to localhost port (default is 8080). By default it maps the application service port 8080 to host 8080

Note
  • The first build will be bit slower as it needs to cache the maven artifacts in nexus maven repository

  • You can watch the status via `kubectl get pods -w `, use Ctrl+c to terminate the watch

Once you see your application running alongside nexus (if you had deployed earlier):

NAME                                           READY   STATUS    RESTARTS   AGE
nexus-5585f7fcf6-jk6j7                         1/1     Running   0          5h3m
skaffold-quarkus-helloworld-6f99cbb648-lsqwh   1/1     Running   0          5s

Try opening the url http://locahost:8080/hello, which should show a message like Welcome to Quarkus!! from the GreetingResource.java

Now make any changes to the sources in your editor and try refreshing the browser you will see Quarkus live reload happening as usual on the terminal where you had started skaffold dev without the skaffold-quarkus-hello-world redeployed.

Tip

Though the demo application provides build.cmd for windows users I personally recommend WSL and VS Code Remote Development

Quarkus Production mode

To run Quarkus application in production mode, we need to use the multi stage docker build; to build the quarkus application container image and use it in Kubernetes application deployment.

The following commands starts a one time deployment of Quarkus application with the port-forward and it also tails the logs from the application once its up and running.

Note

If you want to deploy Quarkus JVM image then run the following command before running skaffold:

cp src/main/docker/Dockerfile.jvm Dockerfile

If you want to deploy Quarkus Native image then run the following command before running skaffold:

cp src/main/docker/Dockerfile.native Dockerfile
Warning

You might face a build failure in pulling the image quay.io/quarkus/centos-quarkus-maven:19.3.1-java8, as Quarkus repo in https://quay.io is not v2_2 enabled. If you encounter the issue with pull then do a manual pull docker pull quay.io/quarkus/centos-quarkus-maven:19.3.1-java8

skaffold run --port-forward --tail

Cleanup

To delete the application:

skaffold delete

skaffold-quarkus-helloworld's People

Contributors

kameshsampath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.