Slide 1

Slide 1 text

Austin Dewey Senior Consultant, Red Hat Deploying a Quarkus-Based Application in OpenShift Using Helm Andrew Block Distinguished Architect, Red Hat

Slide 2

Slide 2 text

https://quarkus.io/

Slide 3

Slide 3 text

https://quarkus.io/

Slide 4

Slide 4 text

Quarkus Run Modes Understanding the JVM and Native Run Modes JVM A Quarkus application running as bytecode on a JVM Native A Quarkus application as a native binary

Slide 5

Slide 5 text

Building a Quarkus Image in OpenShift A High-Level Abstraction of OCP BuildConfigs Git Repo ImageStream BuildConfig OpenShift Project 1 2 3 1 Clone the application from Git 2 Build the application in OCP 3 Publish the image to an ImageStream

Slide 6

Slide 6 text

BuildConfigs Can Be Challenging to Create Builds Require Both OpenShift and Quarkus Expertise ▸ An understanding of Source and Docker strategies is key ・ Which s2i builder should you use? ・ How should your Dockerfile be written? ▸ Need to know how to configure a BuildConfig ▸ JVM and Native modes require different configurations

Slide 7

Slide 7 text

Building Is Only the First Part...Now You Need to Deploy Here’s a Few Resources to Consider Each resource has its own configuration. ▸ OpenShift expertise is required to understand the available options. ▸ Quarkus expertise is required to understand the best practices behind deploying a Quarkus app.

Slide 8

Slide 8 text

Helm to the Rescue! The Kubernetes Package Manager

Slide 9

Slide 9 text

Helm at a Glance ● 2016 - Joined CNCF ● 2020 - Graduated status Active development community Top level CNCF Project ● 13,000+ contributors ● 1,700+ contributing companies ● 9,500+ code commits Project Overview ● https://helm.sh/ ● https://github.com/helm/helm

Slide 10

Slide 10 text

Helm Creates a Wrapper (Called “Charts”) Around OCP Resources { Users can then create each of these resources using a single command...helm install.

Slide 11

Slide 11 text

Helm Allows YAML Definitions to be Dynamically Generated apiVersion: build.openshift.io/v1 kind: BuildConfig . . . spec: . . . source: type: Git git: uri: {{ .Values.build.uri }} contextDir: {{ .Values.build.contextDir }} {{- if and .Values.build.native.useDefaultDockerfile (eq .Values.build.mode “native”) }} dockerfile: |- FROM registry.redhat.com/quarkus/mandrel-20-rhel8 AS builder . . . {{- end }} strategy: {{- if eq .Values.build.mode “jvm” }} type: Source sourceStrategy: . . . apiVersion: apps/v1 kind: Deployment metadata: . . . spec: replicas: {{ .Values.deploy.replicas }} . . . template: spec: containers: - name: web image: {{ .Release.Name }}:{{ .Values.image.tag }} {{- if .Values.deploy.resources }} resources: {{- toYaml .Values.deploy.resources | nindent 12 }} {{- end }} . . .

Slide 12

Slide 12 text

Users Configure Their Installation Using “Values” build: uri: https://github.com/deweya/quarkus-quickstarts contextDir: getting-started mode: jvm deploy: resources: limits: cpu: 500m memory: 2Gi Create a values.yaml file $ helm install quarkus-app redhat-charts/quarkus --values values.yaml Install the Helm chart BuildConfig ImageStream

Slide 13

Slide 13 text

Installing Charts From Helm Chart Repositories Using the Helm CLI Users can easily install Helm charts by first adding a Helm chart repository using the Helm CLI. $ helm repo add redhat-charts https://redhat-developer.github.io/re dhat-helm-charts/index.yaml Then, users can install charts under the chart repository they added. $ helm install quarkus-app redhat-charts/quarkus --values values.yaml 1 2

Slide 14

Slide 14 text

Installing Charts From Helm Chart Repositories Using the OpenShift UI The Red Hat Helm Chart Repository is already configured OOTB. Optionally, admins can add additional repos by creating a HelmChartRepository resource $ cat <

Slide 15

Slide 15 text

The Quarkus Helm Chart + ▸ A Red Hat Runtimes initiative ▸ Released to the Red Hat Helm Chart Repository as Alpha ・ https://github.com/redhat-developer/re dhat-helm-charts

Slide 16

Slide 16 text

JVM and Native Builds JVM Creates an s2i build, using the java:11 s2i builder by default build: mode: jvm . . . Build mode is determined by the build.mode value Native Creates a Docker build, using a default inline Dockerfile If build.mode is jvm (default) If build.mode is native

Slide 17

Slide 17 text

Default Dockerfile for Native Builds source: type: Git git: uri: {{ .Values.build.uri }} ref: {{ .Values.build.ref }} {{- if and .Values.build.native.useDefaultDockerfile (eq .Values.build.mode "native") }} dockerfile: |- FROM registry.redhat.io/quarkus/mandrel-20-rhel8 AS builder USER root WORKDIR /build/ COPY . /build/ RUN ./mvnw clean package -Pnative FROM registry.redhat.io/ubi8/ubi-minimal WORKDIR /deployments/ COPY --from=builder /build/target/*-runner /deployments/application RUN chmod 110 /deployments/application CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] {{- end }}

Slide 18

Slide 18 text

Externalized Application Properties deploy: applicationProperties: enabled: true mountPath: /deployments/config/ properties: |- quarkus.http.port=8081 greeting.message=Hello! Application properties can be externalized by leveraging the deploy.applicationProperties values Creates A ConfigMap with the specified application properties A volume mount at /deployments/config/

Slide 19

Slide 19 text

ConfigChange and ImageChange Triggers $ helm install quarkus-app redhat-charts/quarkus --values values.yaml Install the Helm chart Build automatically starts Pods automatically roll out Build is finished

Slide 20

Slide 20 text

Freeform Fields Environment variables Init and sidecar containers Volumes and volume mounts Resources Liveness and readiness probes Ports

Slide 21

Slide 21 text

The End Result BuildConfig ImageStream Optional build: uri: https:/my-repo.com/quarkus-app And this can all be configured with a single value, at a minimum!

Slide 22

Slide 22 text

Example Quarkus Project Structure .helm/ values.yaml src/ mvnw pom.xml # Other project files Used to configure the Quarkus Helm chart Very useful for CI/CD tooling and creating repeatable builds and deployments Alternatively, these values can be configured in the UI for short-term use cases

Slide 23

Slide 23 text

Quarkus Resources Quarkus Guides https://quarkus.io/guides/ Quarkus Project Repository https://github.com/quarkusio/quarkus Zulip https://quarkusio.zulipchat.com/login/ Quarkus YouTube Channel https://www.youtube.com/channel/UCaW8QG_Q oIk_FnjLgr5eOqg

Slide 24

Slide 24 text

Helm Resources Helm Documentation https://helm.sh/docs/ Helm Project Repository https://github.com/helm/helm Slack https://slack.kubernetes.io/ (#helm) Interactive Lab https://learn.openshift.com/developing-on-openshift/helm/ Learn Helm https://www.packtpub.com/cloud-networking/learn-helm Contact the Red Hat Helm Team [email protected]

Slide 25

Slide 25 text

Demo! Let’s build and deploy a self-healing Quarkus application using the Quarkus Helm Chart +

Slide 26

Slide 26 text

linkedin.com/company/red-hat youtube.com/user/RedHatVideos facebook.com/redhatinc twitter.com/RedHat 26 Red Hat is the world’s leading provider of enterprise open source software solutions. Award-winning support, training, and consulting services make Red Hat a trusted adviser to the Fortune 500. Thank you