Skip to content

ibm-garage-dach/qhello

Repository files navigation

E2E kubernetes example

This example was bootstrapped from the Quarkus getting started tutorial. I have added the following 3 files in the root directorywhich are sufficient to run it on kubernetes:

  • Dockerfile - this is about the simplest docker file that will build a container to run the app. For more enterprise-ready docker files that were generated by quarkus, see src/main/docker
  • deployment.yaml - this is a simple kubernetes deployment file. It will automatically create a ReplicaSet that manages a number of Pods
  • service.yaml - this creates a NodePort service that allows the deployment to be accessed from outside the cluster

The v2 branch of this repository has an example state of this repo after an update has been deployed.

Note: in production, it is likely that the deployment.yaml and service.yaml would live in a separate gitops repository.

Demo Script

  1. Run application using ./mvnw compile quarkus:dev
  2. Run curl http://localhost:8080/hello

Build Image

As if I were a delivery pipeline...

  1. Run the tests ./mvnw test
  2. Show the Dockerfile
  3. Run ./mvnw package
  4. Show the jar in the target folder
  5. Show the other docker files
  6. Build it: docker build -t qhello:1 .
  7. Run it locally docker run -p 12345:8080 qhello:1

Deploy to registry

  1. List the images ic cr images --restrict dom-test
  2. Tag the image docker tag qhello:1 us.icr.io/dom-test/qhello:1
  3. (Skipped) Push it docker push us.icr.io/dom-test/qhello:1

Set it up on k8s

  1. kubectl apply -f deployment.yaml
  2. kubectl apply -f service.yaml

Edit code

  1. Edit the code - change the message
  2. Run curl http://localhost:8080/hello again

Update deployment

  1. Run & fix the tests ./mvnw test
  2. Package again ./mvnw package
  3. Build it: docker build -t qhello:2 .
  4. Tag it: docker tag qhello:2 us.icr.io/dom-test/qhello:2
  5. (Skipped) Push it docker push us.icr.io/dom-test/qhello:2
  6. Edit the deployment.yaml to ref the new version
  7. Apply the changes kubectl apply -f deployment.yaml

Original quarkus README.md below...

getting-started project

This project uses Quarkus, the Supersonic Subatomic Java Framework.

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .

Running the application in dev mode

You can run your application in dev mode that enables live coding using:

./mvnw compile quarkus:dev

Packaging and running the application

The application can be packaged using:

./mvnw package

It produces the getting-started-1.0.0-SNAPSHOT-runner.jar file in the /target directory. Be aware that it’s not an über-jar as the dependencies are copied into the target/lib directory.

If you want to build an über-jar, execute the following command:

./mvnw package -Dquarkus.package.type=uber-jar

The application is now runnable using java -jar target/getting-started-1.0.0-SNAPSHOT-runner.jar.

Creating a native executable

You can create a native executable using:

./mvnw package -Pnative

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:

./mvnw package -Pnative -Dquarkus.native.container-build=true

You can then execute your native executable with: ./target/getting-started-1.0.0-SNAPSHOT-runner

If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.

RESTEasy JAX-RS

A Hello World RESTEasy resource

Guide: https://quarkus.io/guides/rest-json

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published