Skip to content

[OPENJDK-2992] Create DeploymentConfig and Route for jlink apps #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions templates/jlink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ prepare UBI9 OpenJDK ImageStreams with `jlink-dev` support.

2. Within your OpenShift project,

oc create imagestream ubi9-openjdk-17
oc create imagestream openjdk-17-jlink-tech-preview

3. You may need to configure your container engine to not TLS-verify the OpenShift
registry. For Docker, add the following to `/etc/docker/daemon.json` and restart
Expand All @@ -37,7 +37,7 @@ prepare UBI9 OpenJDK ImageStreams with `jlink-dev` support.
5. tag and push the dev image into it. The OpenShift console gives you the
exact URI for your instance

docker tag ubi9/openjdk-17:1.18 default-route-openshift-image-registry.apps-crc.testing/jlink1/ubi9-openjdk-17:1.18
docker tag openjdk-tech-preview/openjdk-17-jlink-rhel9:1.18 default-route-openshift-image-registry.apps-crc.testing/jlink1/openjdk-17-jlink-tech-preview:1.18
docker push default-route-openshift-image-registry.apps-crc.testing/jlink1/ubi9-openjdk-17:1.18

## Stage 1: Load the template into OpenShift and instantiate it
Expand All @@ -57,13 +57,17 @@ Some suitable test values for the parameters are
* REF: master
* CONTEXT_DIR: quarkus-quickstarts/getting-started-3.9.2-uberjar
* APPNAME: quarkus-quickstart
* TARGET_PORT: 8080
* SERVICE_PORT: 8080

oc process \
-p JDK_VERSION=17 \
-p APP_URI=https://github.com/jboss-container-images/openjdk-test-applications \
-p REF=master \
-p CONTEXT_DIR=quarkus-quickstarts/getting-started-3.9.2-uberjar \
-p APPNAME=quarkus-quickstart \
-p TARGET_PORT=8080 \
-p SERVICE_PORT=8080 \
templates/jlink-app-template \
| oc create -f -

Expand Down
93 changes: 87 additions & 6 deletions templates/jlink/jlinked-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ parameters:
generate: expression
from: "[a-zA-Z0-9]{16}"
required: true
- description: Target port for the created Route
name: TARGET_PORT
value: "8080"
required: true
- description: Port for the created Service to listen on
name: SERVICE_PORT
value: "8181"
required: true
message: "... The GitHub webhook secret is ${GITHUB_WEBHOOK_SECRET} ..."
##############################################################################
# Following are the objects(imagestream and buildconfigs) for all the 3-stages
Expand All @@ -41,7 +49,7 @@ objects:
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: ${APPNAME}-ubi9-openjdk-${JDK_VERSION}-jlink
name: ${APPNAME}-openjdk-${JDK_VERSION}-jlink-tech-preview
labels:
app: ${APPNAME}
app.kubernetes.io/part-of: ${APPNAME}
Expand Down Expand Up @@ -78,24 +86,27 @@ objects:
dockerStrategy:
from:
kind: ImageStreamTag
name: ubi9-openjdk-${JDK_VERSION}:${BUILDER_IMAGE_TAG} # Refer README.md to create this ImageStream
name: openjdk-${JDK_VERSION}-jlink-tech-preview:${BUILDER_IMAGE_TAG} # Refer README.md to create this ImageStream
output:
to:
kind: ImageStreamTag
name: ${APPNAME}-ubi9-openjdk-${JDK_VERSION}-jlink:latest
name: ${APPNAME}-openjdk-${JDK_VERSION}-jlink-tech-preview:latest
triggers:
- type: ConfigChange
- type: ImageChange
imageChange:
from:
kind: ImageStreamTag
name: ubi9-openjdk-${JDK_VERSION}:${BUILDER_IMAGE_TAG}
name: openjdk-${JDK_VERSION}-jlink-tech-preview:${BUILDER_IMAGE_TAG}
##############################################################################
# stage-2: Output ImageStream
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: ${APPNAME}-intermediate
labels:
app: ${APPNAME}
app.kubernetes.io/part-of: ${APPNAME}
spec:
lookupPolicy:
local: false
Expand All @@ -119,7 +130,7 @@ objects:
sourceStrategy:
from:
kind: ImageStreamTag
name: ${APPNAME}-ubi9-openjdk-${JDK_VERSION}-jlink:latest # Output Imagestream from stage-1
name: ${APPNAME}-openjdk-${JDK_VERSION}-jlink-tech-preview:latest # Output Imagestream from stage-1
pullPolicy: Always
env:
- name: S2I_ENABLE_JLINK
Expand All @@ -136,7 +147,7 @@ objects:
imageChange:
from:
kind: ImageStreamTag
name: ${APPNAME}-ubi9-openjdk-${JDK_VERSION}-jlink:latest # Output of stage-1 which serves as input to stage-2
name: ${APPNAME}-openjdk-${JDK_VERSION}-jlink-tech-preview:latest # Output of stage-1 which serves as input to stage-2
- type: GitHub
github:
secret: ${GITHUB_WEBHOOK_SECRET}
Expand Down Expand Up @@ -233,3 +244,73 @@ objects:
from:
kind: ImageStreamTag
name: ${APPNAME}-ubimicro:latest # ImageStreamTag for registry.access.redhat.com/ubi9/ubi-micro
##############################################################################
# DeploymentConfig and Route object specs
# DeploymentConfigs are discouraged, however the documentation sugggests to still
# use them if features are missing from Deployments, which in our case they are.
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: ${APPNAME}-jlinked-app-deployment
annotations:
template.alpha.openshift.io/wait-for-ready: "true"
labels:
app: ${APPNAME}
app.kubernetes.io/part-of: ${APPNAME}
spec:
replicas: 1
selector:
app: ${APPNAME}
template:
metadata:
labels:
app: ${APPNAME}
app.kubernetes.io/part-of: ${APPNAME}
spec:
containers:
- name: ${APPNAME}-jlinked-app-container
image: ${APPNAME}-lightweight-image:latest
ports:
- containerPort: ${{TARGET_PORT}}
protocol: TCP
strategy:
type: Rolling
triggers:
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- ${APPNAME}-jlinked-app-container
from:
kind: ImageStreamTag
name: '${APPNAME}-lightweight-image:latest'
namespace: default
- type: ConfigChange
- apiVersion: v1
kind: Service
metadata:
name: ${APPNAME}-jlinked-app-service
labels:
app: ${APPNAME}
app.kubernetes.io/part-of: ${APPNAME}
spec:
selector:
app: ${APPNAME}
ports:
- protocol: TCP
name: target-${TARGET_PORT}-tcp
port: ${{SERVICE_PORT}}
targetPort: ${{TARGET_PORT}}
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: ${APPNAME}-jlinked-app-route
labels:
app: ${APPNAME}
app.kubernetes.io/part-of: ${APPNAME}
spec:
to:
kind: Service
name: ${APPNAME}-jlinked-app-service
port:
targetPort: ${{TARGET_PORT}}