0% found this document useful (0 votes)
56 views2 pages

Quarkus Kubernetes Cheatsheet

1. Quarkus integrates with Kubernetes through extensions that generate Kubernetes resource definitions. 2. The extensions allow building container images and deploying to Kubernetes through Maven goals. Specific extensions include Jib, Docker, and S2I for building images and Dekorate for generating Kubernetes resources. 3. Configuration options allow customizing the generated resources, including replicas, probes, mounts, secrets, labels, and annotations. Health checks integrate with the resources. Setting a flag deploys the resources after building.

Uploaded by

Perico Martinez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views2 pages

Quarkus Kubernetes Cheatsheet

1. Quarkus integrates with Kubernetes through extensions that generate Kubernetes resource definitions. 2. The extensions allow building container images and deploying to Kubernetes through Maven goals. Specific extensions include Jib, Docker, and S2I for building images and Dekorate for generating Kubernetes resources. 3. Configuration options allow customizing the generated resources, including replicas, probes, mounts, secrets, labels, and annotations. Health checks integrate with the resources. Setting a flag deploys the resources after building.

Uploaded by

Perico Martinez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CHEAT SHEET

Quarkus & Kubernetes I

Th is ch eat sh eet covers th e in tegration s you can n d in th e form of exten sion s betw een Qu arku s an d Ku bern etes.

CREATING THE PROJECT quarkus.container-image.build


Flag to set if th e image sh ou ld be bu ilt, defau lts to false.
mvn "io.quarkus:quarkus-maven-plugin:1 .4.0.Final:create" \
-DprojectGroupId="org.acme" \ quarkus.container-image.push
-DprojectArtifactId="greeting" \ Flag to set if th e image sh ou ld be pu sh ed, defau lts to false.
-DprojectVersion="1 .0-SNAPSHOT" \
-DclassName="org.acme.GreetingResource" \ Speci c bu ilders:
-Dextensions="kubernetes, jib" \
Jib
-Dpath="/hello"

You can u se Jib to bu ild th e con tain er image. Jib bu ilds Docker an d OCI images
You can gen erate th e project in h ttps://code.qu arku s.io/ an d selectin g for Java application s in a dockerless fash ion .
Tip
kubernetes an d jib exten sion s. ./mvnw quarkus:add-extensions -Dextensions="jib"
Speci c properties for th e Jib exten sion are:

NATIVE EXECUTABLE SUPPORT quarkus.container-image-jib.base-jvm-image

You can bu ild a n ative image by u sin g GraalVM. Bu t sin ce Ku bern etes w orks Th e base image to u se for th e Jib bu ild, defau lts to fabric8/java-alpine-
w ith con tain ers, you n eed to create th e n ative execu table in side a con tain er. openjdk8-jre.
Qu arku s allow s you to do th at by ru n n in g th e follow in g comman d: quarkus.container-image-jib.base-native-image
./mvnw package -Pnative -Dquarkus.native.container-build=true
Th e base image to u se for th e n ative bu ild, defau lts to
Or u sin g podman:
registry.access.redhat.com/ubi8/ubi-minimal.
./mvnw package -Pnative -Dquarkus.native.container-runtime=podman -
Dquarkus.native.container-build=true quarkus.container-image-jib.jvm-arguments
Th e argu men ts to pass to Java, defau lts to -Dquarkus.http.host=0.0.0.0,-
Djava.util.logging.manager=org.jboss.logmanager.LogManager.
CONTAINER IMAGE CREATION
quarkus.container-image-jib.native-arguments
Qu arku s comes w ith defau lt Dockerfiles to bu ild th e con tain er. Th ey are fou n d
in src/main/docker. Th e argu men ts to pass to th e n ative application , defau lts to -
Dquarkus.http.host=0.0.0.0.
Dockerfile.jvm
quarkus.container-image-jib.environment-variables
It can be u sed to create a con tain er con tain in g th e gen erated Java les (ru n n er
Map of en viron men t variables.
JAR + lib folder).
Dockerfile.native
It can be u sed to create a con tain er con tain in g th e gen erated n ative
Dock er
execu table le.
You can u se th e Docker exten sion to bu ild th e con tain er image u sin g Docker
You can u se Docker to create th e con tain er image: docker build -f CLI.
src/main/docker/Dockerfile.native -t quarkus/getting-started . or you can leverage ./mvnw quarkus:add-extensions -Dextensions="docker"
to Qu arku s th e creation an d release of th e con tain er images. Several exten sion s Speci c properties for th e Docker exten sion are:
are provided to make it so.
quarkus.container-image-docker.dockerfile-jvm-path
Stan dard properties th at can be set as Java system properties or in th e
src/main/resources/application.properties. Path to th e JVM Docker le, defau lts to
${project.root}/src/main/docker/Dockerfile.jvm.
quarkus.container-image.group
quarkus.container-image-docker.dockerfile-native-path
Th e grou p/repository of th e image, defau lts to ${user.name}.
Path to th e n ative Docker le, defau lts to
quarkus.container-image.name ${project.root}/src/main/docker/Dockerfile.native.
Th e n ame of th e image, defau lts to th e application n ame.
quarkus.container-image.tag S2I
Th e tag of th e image, defau lts to th e application version .
quarkus.container-image.registry You can u se th e S2I to bu ild th e con tain er image.
./mvnw quarkus:add-extensions -Dextensions="s2i"
Th e registry to u se for pu sh in g, defau lts to docker.io. Speci c properties for th e S2I exten sion are:
quarkus.container-image.username
quarkus.container-image-s2i.base-jvm-image
Th e registry u sern ame.
Th e base image to u se for th e s2i bu ild, defau lts to fabric8/java-alpine-
quarkus.container-image.password openjdk8-jre.
Th e registry passw ord. quarkus.container-image-s2i.base-native-image
quarkus.container-image.insecure Th e base image to u se for th e n ative bu ild, defau lts to
Flag to allow in secu re registries, defau lts to false. registry.access.redhat.com/ubi8/ubi-minimal.

Build here. Go any where. developers.redhat.com | @RHdevelopers


CHEAT SHEET

KUBERNETES

Qu arku s u se th e Dekorate project to gen erate Ku bern etes resou rces.


Ru n n in g ./mvnw package th e Ku bern etes resou rces are created at
target/kubernetes/ directory.
You can ch oose th e target deploymen t type by settin g th e
quarkus.kubernetes.deployment-target property. Possible valu es are kubernetes,
openshift an d knative. Th e defau lt target is kubernetes.
You can cu stomize th e gen erated resou rce by settin g speci c properties in
application.properties. Fu ll list of con gu rable elemen ts are:
h ttps://qu arku s.io/gu ides/ku bern etes#con gu ration -option s
src/main /resou rces/application .properties
quarkus.kubernetes.replicas=3
quarkus.kubernetes.readiness-probe.period-seconds=45
quarkus.kubernetes.mounts.github-token.path=/deployment/github
quarkus.kubernetes.mounts.github-token.read-only=true
quarkus.kubernetes.secret-volumes.github-token.volume-name=github-token
quarkus.kubernetes.secret-volumes.github-token.secret-name=greeting-security
quarkus.kubernetes.secret-volumes.github-token.default-mode=420
quarkus.kubernetes.config-map-volumes.github-token.config-map-name=my-secret
quarkus.kubernetes.labels.foo=bar
quarkus.kubernetes.annotations.foo=bar
quarkus.kubernetes.expose=true

Moreover, th e gen erated resou rces are in tegrated w ith MicroPro le Health spec,
registerin g liven ess/readin ess probes based on th e h ealth ch ecks de n ed u sin g
th e spec.
To deploy th e gen erated resou rces au tomatically, you n eed to set
quarkus.container.deploy ag to true.
./mvnw clean package -Dquarkus.kubernetes.deploy=true
Settin g th is ag to true, makes th e bu ild an d pu sh ags from th e container-
image set to true too.
Ku bern etes exten sion u ses th e Ku bern etes Clien t to deploy resou rces. By
defau lt, Ku bern etes Clien t reads con n ection properties from th e ~/.kube/config
folder bu t you can set th em too by u sin g some of th e kubernetes-client
properties:

quarkus.kubernetes-client.trust-certs
Tru st self-sign ed certi cates, defau lts to false.
quarkus.kubernetes-client.master-url
URL of Ku bern etes API server.
quarkus.kubernetes-client.namespace
Defau lt n amespace.
quarkus.kubernetes-client.ca-cert-file
CA certi cate data.
quarkus.kubernetes-client.client-cert-file
Clien t certi cate le.
quarkus.kubernetes-client.client-cert-data
Clien t certi cate data.
quarkus.kubernetes-client.client-key-data
Clien t key data.
quarkus.kubernetes-client.client-key-algorithm
Clien t key algorith m.
quarkus.kubernetes-client.username
Usern ame.
quarkus.kubernetes-client.password
Passw ord.

Author Alex Soto


Java Champion, Working at Red Hat

Build here. Go any where. developers.redhat.com | @RHdevelopers

You might also like