Skip to content

Commit c540151

Browse files
authored
Merge pull request #454 from Josh-Matsuoka/jlink-stage-1
[OPENJDK-2686] Jlink stage 1 - BuildConfig and Imagestream for creating a builder image with the jmods rpm installed
2 parents d2a5290 + ae07f04 commit c540151

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# OpenShift-JLink PoC
2+
3+
Try it out:
4+
5+
## Stage 1: create ubi9 jlink imagestream and push a ubi9 image with jmods installed to it.
6+
7+
You need:
8+
9+
1. Access to an OpenShift instance, such as crc
10+
2. UBI9 OpenJDK ImageStreams. You can load them from this repository with
11+
12+
oc create -f templates/ubi9-community-image-streams.json
13+
14+
Steps to produce the imagestream and image:
15+
16+
1. install the template
17+
18+
oc create -f templates/jlink/jlink-builder/jlink-builder-template.yaml
19+
20+
This will create a Template called jlink-builder-template, you should see
21+
22+
template.template.openshift.io/jlink-builder-template created
23+
24+
and after running oc get template, it should be in the list as
25+
26+
jlink-builder-template Template to produce an imagestream and buildconfig for a Jlink builder image 1 (all set) 2
27+
28+
2. Set the parameters and create the imagestream and buildconfig from the template.
29+
30+
The template for now defines a single parameter, JDK_VERSION. Setting this will set the version of the builder image used in the BuildConfig. Currently suppoted values are 11, 17, and 21. By default this will be 11.
31+
32+
oc process --parameters jlink-builder-template
33+
34+
NAME DESCRIPTION GENERATOR VALUE
35+
JDK_VERSION JDK version to produce a jmods image for 11
36+
37+
In order to set the JDK version, you will need to use the -p flag of oc process. To process the template and create the imagestreams, simply run
38+
39+
oc process jlink-builder-template -p JDK_VERSION=11 | oc create -f -
40+
41+
imagestream.image.openshift.io/ubi9-openjdk-11-jlink created
42+
buildconfig.build.openshift.io/jlink-builder-jdk-11 created
43+
44+
3. Start and observe the build
45+
46+
Start the build using
47+
48+
oc start-build jlink-builder-jdk-11
49+
50+
build.build.openshift.io/jlink-builder-jdk-11-1 started
51+
52+
Then observe it by using
53+
54+
oc logs -f bc/jlink-builder-jdk-11
55+
56+
## Stage 2: build and analyse application with OpenShift source-to-image (S2I)
57+
58+
TODO
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
apiVersion: template.openshift.io/v1
3+
kind: Template
4+
metadata:
5+
annotations:
6+
description: Template to produce an imagestream and buildconfig for a Jlink builder image
7+
name: jlink-builder-template
8+
parameters:
9+
- description: JDK version to produce a jmods image and imagestream for
10+
name: JDK_VERSION
11+
value: "11"
12+
required: true
13+
objects:
14+
- apiVersion: image.openshift.io/v1
15+
kind: ImageStream
16+
metadata:
17+
name: ubi9-openjdk-${JDK_VERSION}-jlink
18+
spec:
19+
lookupPolicy:
20+
local: false
21+
- apiVersion: build.openshift.io/v1
22+
kind: BuildConfig
23+
metadata:
24+
name: jlink-builder-jdk-${JDK_VERSION}
25+
labels:
26+
app: jlink-builder-jdk-${JDK_VERSION}
27+
spec:
28+
source:
29+
dockerfile: |
30+
FROM -
31+
USER 0
32+
RUN microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install -y java-${JDK_VERSION}-openjdk-jmods
33+
USER 185
34+
strategy:
35+
dockerStrategy:
36+
from:
37+
kind: ImageStreamTag
38+
name: ubi9-openjdk-${JDK_VERSION}:1.18
39+
output:
40+
to:
41+
kind: ImageStreamTag
42+
name: ubi9-openjdk-${JDK_VERSION}-jlink:latest

0 commit comments

Comments
 (0)