Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Created April 16, 2021 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaeltuelho/af46489658e52b865be14be25c5b6123 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/af46489658e52b865be14be25c5b6123 to your computer and use it in GitHub Desktop.
Quarkus App DeploymentConfig for Openshift 4 using ubi8/openjdk-8 image
kind: DeploymentConfig
apiVersion: apps.openshift.io/v1
metadata:
annotations:
openshift.io/generated-by: OpenShiftNewApp
name: my-quarkus-app
spec:
strategy:
type: Rolling
rollingParams:
updatePeriodSeconds: 1
intervalSeconds: 1
timeoutSeconds: 600
maxUnavailable: 25%
maxSurge: 25%
resources: {}
activeDeadlineSeconds: 21600
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- rhpam-client-app-quarkus
from:
kind: ImageStreamTag
namespace: rhpam13
name: 'my-quarkus-app:latest'
replicas: 1
revisionHistoryLimit: 10
test: false
selector:
app: my-quarkus-app
deploymentconfig: my-quarkus-app
template:
metadata:
labels:
app: my-quarkus-app
deploymentconfig: my-quarkus-app
annotations:
openshift.io/generated-by: OpenShiftNewApp
spec:
containers:
- name: rhpam-client-app-quarkus
image: >-
image-registry.openshift-image-registry.svc:5000/yournamespace/yourimagename
ports:
- containerPort: 8080
protocol: TCP
env:
- name: JAVA_OPTS_APPEND
value: >-
-Dmy.system.prop.here=anyvalue
- name: JAVA_LIB_DIR
value: lib
- name: JAVA_MAIN_CLASS
value: io.quarkus.runner.GeneratedMain
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
schedulerName: default-scheduler
@rafaeltuelho
Copy link
Author

rafaeltuelho commented Apr 16, 2021

Here is the BuildConfig to generate the quarkus app-image for deployment (via DC)

notice the use of some env vars to customize the Maven build

impor the ubi8-openjdk-8 image stream into your namespace

oc import-image --confirm ubi8/openjdk-8 --from=registry.access.redhat.com/ubi8/openjdk-8 -n {{ project_name }}
kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftNewApp
  name: my-quarkus-app
spec:
  output:
    to:
      kind: ImageStreamTag
      name: 'my-quarkus-app:latest'
  resources: {}
  successfulBuildsHistoryLimit: 5
  failedBuildsHistoryLimit: 5
  strategy:
    type: Source
    sourceStrategy:
      from:
        kind: ImageStreamTag
        name: 'openjdk-8:latest'
      env:
          - name: MAVEN_REPOS
            value: NEXUS_CUSTOM_GROUP,NEXUS_SNAPSHOT
          - name: NEXUS_CUSTOM_GROUP_MAVEN_REPO_ID
            value: nexus-ocp-custom
          - name: NEXUS_CUSTOM_GROUP_MAVEN_REPO_NAME
            value: nexus-ocp-custom
          - name: NEXUS_CUSTOM_GROUP_MAVEN_REPO_URL
            value: "{{ nexus_url }}/repository/customgroup/"
          - name: NEXUS_CUSTOM_GROUP_MAVEN_REPO_USERNAME
            value: admin
          - name: NEXUS_CUSTOM_GROUP_MAVEN_REPO_PASSWORD
            value: nexus_pass
          - name: MAVEN_S2I_GOALS # in case you want to deploy your artifact to an external maven repo
            value: "package install deploy"
          - name: NEXUS_SNAPSHOT_MAVEN_REPO_ID
            value: nexus-ocp-snapshots
          - name: NEXUS_SNAPSHOT_MAVEN_REPO_NAME
            value: nexus-ocp
          - name: NEXUS_SNAPSHOT_MAVEN_REPO_URL
            value: {{ nexus_url }}/repository/snapshots/
          - name: NEXUS_SNAPSHOT_MAVEN_REPO_USERNAME
            value: admin
          - name: NEXUS_SNAPSHOT_MAVEN_REPO_PASSWORD
            value: nexus_pass
          - name: MAVEN_OPTS # in case you have a very heavy build
            value: "-Xms1024m -Xmx2048m -XX:+ExitOnOutOfMemoryError"
          - name: MAVEN_ARGS_APPEND
            value: >-
              -DskipTests
              -Dmaven.wagon.http.ssl.insecure=true
              -Dmaven.wagon.http.ssl.allowall=true
              -Dmaven.wagon.http.ssl.ignore.validity.dates=true
          - name: MAVEN_S2I_ARTIFACT_DIRS # in case you have multimodule
            value: "quarkus-impl-services/quarkus-impl-services-api-impl/target"
          - name: ARTIFACT_COPY_ARGS # in case you want to copy additional artififacts needed by your app startup
            value: "-r lib *.jar"
  postCommit: {}
  source:
    type: Git
    git:
      uri: >-
        https://your.git.url.git
      ref: master
    sourceSecret:
      name: github
  triggers:
    - type: GitHub
      github:
        secret: d6zd8VVaEyxnVprE5pH3
    - type: Generic
      generic:
        secret: 82WIOQM8IFnReyVrlmA7
    - type: ConfigChange
    - type: ImageChange
      imageChange:
        lastTriggeredImageID: >-
          registry.access.redhat.com/ubi8/openjdk-8@sha256:a7e3f8af8fc7403e2efa5fd36e1570ce920e425f3e1e026350aa569caf49fcb8
  runPolicy: Serial
status:
  lastVersion: 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment