Share
Embed
Deploying a Quarkus-Based Application in OpenShift Using Helm
Red Hat Livestreaming
December 16, 2020
Transcript
26 slides
-
Austin Dewey Senior Consultant, Red Hat Deploying a Quarkus-Based Application
in OpenShift Using Helm Andrew Block Distinguished Architect, Red Hat -
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 -
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 -
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 -
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. -
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 -
Helm Creates a Wrapper (Called “Charts”) Around OCP Resources {
Users can then create each of these resources using a single command...helm install. -
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 }} . . . -
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 -
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 -
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 <<EOF | oc apply -f - apiVersion: helm.openshift.io/v1beta1 kind: HelmChartRepository metadata: name: redhat-charts spec: name: redhat-charts connectionConfig: url: https://redhat-developer.github.io/re dhat-helm-charts/index.yaml EOF Users can install charts using the OpenShift UI -
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 -
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 -
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 }} -
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/ -
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 -
Freeform Fields Environment variables Init and sidecar containers Volumes and
volume mounts Resources Liveness and readiness probes Ports -
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! -
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 -
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 -
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] -
Demo! Let’s build and deploy a self-healing Quarkus application using
the Quarkus Helm Chart + -
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