jboss-container-images / openjdk

Source To Image (S2I) image for Red Hat OpenShift providing OpenJDK
Apache License 2.0
54 stars 58 forks source link

[OPENJDK-2734] Phase-2 BuildConfig template for intermediate image #469

Closed jhuttana closed 5 months ago

jhuttana commented 6 months ago

This is just for my learning I created and thought to raise a PR to know if there are any mistakes. JIRA: https://issues.redhat.com/browse/OPENJDK-2734

jhuttana commented 6 months ago

Able to create the s2i-build-template

$ oc get templates
NAME                     DESCRIPTION                                                                        PARAMETERS    OBJECTS
jlinked-image-template   Template to produce an imagestream and buildconfig for a Jlinked image             0 (all set)   3
s2i-build-template       Template to produce an imagestream and buildconfig for a Jlinked intermediate...   6 (6 blank)   1
jhuttana commented 6 months ago

With some more changes able to do below steps

$ oc create -f templates/jlink-interim-build-template.yaml 
template.template.openshift.io/s2i-build-template created

$ oc get templates
NAME                     DESCRIPTION                                                                        PARAMETERS      OBJECTS
jlinked-image-template   Template to produce an imagestream and buildconfig for a Jlinked image             0 (all set)     3
s2i-build-template       Template to produce an imagestream and buildconfig for a Jlinked intermediate...   11 (11 blank)   2

$ oc process s2i-build-template -p JDK_VERSION=17 -p S2I_ENABLE_JLINK=true -p S2I_DELETE_SOURCE=false -p LOGGING_SCRIPT_DEBUG=true -p QUARKUS_PACKAGE_TYPE=uber-jar -p APP_NAME=quarkus-quickstarts -p GIT_URI=https://github.com/jboss-container-images/openjdk-test-applications -p GIT_REF=master -p CONTEXT_DIR=quarkus-quickstarts/getting-started-3.0.1.Final-nos2i -p BUILDER_IMAGE=ubi9-openjdk-17-jlink:latest -p OUTPUT_IMAGE_TAG=latest | oc create -f -
imagestream.image.openshift.io/quarkus-quickstarts-17 created
buildconfig.build.openshift.io/quarkus-quickstarts-s2i-build created

When I try to see the parameter values are set or not I am unable to do so

$ oc process --parameters s2i-build-template
NAME                   DESCRIPTION                                              GENERATOR           VALUE
APP_NAME               Name of the application                                                      
GIT_URI                Git repository URL                                                           
GIT_REF                Git branch or tag to build                                                   
CONTEXT_DIR            Context directory which is a directory within git repo                       
BUILDER_IMAGE          Name of the S2I builder image                                                
OUTPUT_IMAGE_TAG       Tag for the output image                                                     
S2I_ENABLE_JLINK       To specify jlink build                                                       
S2I_DELETE_SOURCE                                                                                   
LOGGING_SCRIPT_DEBUG                                                                                
QUARKUS_PACKAGE_TYPE                                                                                
JDK_VERSION        

Ignoring that I just tried to kick a build

$ oc start-build quarkus-quickstarts-s2i-build
The ImageStreamTag "ubi9-openjdk-17-jlink:latest" is invalid: from: Error resolving ImageStreamTag ubi9-openjdk-17-jlink:latest in namespace jaya-test1: imagestreams.image.openshift.io "ubi9-openjdk-17-jlink" not found

So tried to list the imagestream it is looking for

$ oc get is
NAME                     IMAGE REPOSITORY                                                                            TAGS                                                      UPDATED
java                     default-route-openshift-image-registry.apps-crc.testing/jaya-test1/java                     11,8,latest,openjdk-11-ubi8,openjdk-17-ubi8 + 1 more...   4 weeks ago
jlinked-image            default-route-openshift-image-registry.apps-crc.testing/jaya-test1/jlinked-image                                                                      
quarkus-quickstart       default-route-openshift-image-registry.apps-crc.testing/jaya-test1/quarkus-quickstart       latest                                                    4 weeks ago
quarkus-quickstarts      default-route-openshift-image-registry.apps-crc.testing/jaya-test1/quarkus-quickstarts      latest                                                    4 weeks ago
quarkus-quickstarts-17   default-route-openshift-image-registry.apps-crc.testing/jaya-test1/quarkus-quickstarts-17                                                             
ubi8-openjdk-11          default-route-openshift-image-registry.apps-crc.testing/jaya-test1/ubi8-openjdk-11          1.10,1.11,1.12,1.13,1.14,1.15,1.16,1.17 + 2 more...       4 weeks ago
ubi8-openjdk-17          default-route-openshift-image-registry.apps-crc.testing/jaya-test1/ubi8-openjdk-17          1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18                   4 weeks ago
ubi8-openjdk-21          default-route-openshift-image-registry.apps-crc.testing/jaya-test1/ubi8-openjdk-21          1.18                                                      4 weeks ago
ubi8-openjdk-8           default-route-openshift-image-registry.apps-crc.testing/jaya-test1/ubi8-openjdk-8           1.10,1.11,1.12,1.13,1.14,1.15,1.16,1.17 + 2 more...       4 weeks ago

Looks like it is not there where it is looking for the imagestream. I think I have to first create it from Josh's Phase-1 changes.

I tried the steps described in README.md

$ oc create -f templates/jlink/jlink-builder/jlink-builder-template.yaml
template.template.openshift.io/jlink-builder-template created

 oc get templates
NAME                     DESCRIPTION                                                                        PARAMETERS      OBJECTS
jlink-builder-template   Template to produce an imagestream and buildconfig for a Jlink builder image       1 (all set)     2
jlinked-image-template   Template to produce an imagestream and buildconfig for a Jlinked image             0 (all set)     3
s2i-build-template       Template to produce an imagestream and buildconfig for a Jlinked intermediate...   11 (11 blank)   2

$ oc process --parameters jlink-builder-template
NAME                DESCRIPTION                                                GENERATOR           VALUE
JDK_VERSION         JDK version to produce a jmods image and imagestream for                       11

$ oc process jlink-builder-template -p JDK_VERSION=17 | oc create -f -
imagestream.image.openshift.io/ubi9-openjdk-17-jlink created
buildconfig.build.openshift.io/jlink-builder-jdk-17 created

$ oc start-build jlink-builder-jdk-17
The ImageStreamTag "ubi9-openjdk-17:1.18" is invalid: from: Error resolving ImageStreamTag ubi9-openjdk-17:1.18 in namespace jaya-test1: imagestreams.image.openshift.io "ubi9-openjdk-17" not found

$ oc process jlink-builder-template -p JDK_VERSION=11 | oc create -f -
imagestream.image.openshift.io/ubi9-openjdk-11-jlink created
buildconfig.build.openshift.io/jlink-builder-jdk-11 created

$ oc start-build jlink-builder-jdk-11
The ImageStreamTag "ubi9-openjdk-11:1.18" is invalid: from: Error resolving ImageStreamTag ubi9-openjdk-11:1.18 in namespace jaya-test1: imagestreams.image.openshift.io "ubi9-openjdk-11" not found

Here I am struck and I have no clue how to bring this ubi9-openjdk-11 in :)

jmtd commented 6 months ago

Here I am struck and I have no clue how to bring this ubi9-openjdk-11 in :)

From the jlink-dev branch,

oc create -f templates/ubi9-community-image-streams.json
jmtd commented 6 months ago

I'm leaving some review comments in case they are helpful but I had to remind myself that Josh is working on phase 2 and this PR is just for learning purposes.

jhuttana commented 6 months ago

I'm leaving some review comments in case they are helpful but I had to remind myself that Josh is working on phase 2 and this PR is just for learning purposes.

Thank you Jon for taking a look and providing review comments.

jhuttana commented 6 months ago

With latest commit the build is successful and created the output image quarkus-quickstarts-11

$ oc get is
NAME                     IMAGE REPOSITORY                                                                         TAGS                                                      UPDATED
java                     default-route-openshift-image-registry.apps-crc.testing/phase-1/java                     11,8,latest,openjdk-11-ubi8,openjdk-17-ubi8 + 1 more...   19 hours ago
quarkus-quickstarts-11   default-route-openshift-image-registry.apps-crc.testing/phase-1/quarkus-quickstarts-11   latest                                                    3 minutes ago
ubi9-openjdk-11          default-route-openshift-image-registry.apps-crc.testing/phase-1/ubi9-openjdk-11          1.13,1.14,1.15,1.16,1.17,1.18                             19 hours ago
ubi9-openjdk-11-jlink    default-route-openshift-image-registry.apps-crc.testing/phase-1/ubi9-openjdk-11-jlink    latest                                                    14 hours ago
ubi9-openjdk-17          default-route-openshift-image-registry.apps-crc.testing/phase-1/ubi9-openjdk-17          1.13,1.14,1.15,1.16,1.17,1.18                             19 hours ago
ubi9-openjdk-21          default-route-openshift-image-registry.apps-crc.testing/phase-1/ubi9-openjdk-21          1.17,1.18                                                 19 hours ago
jmtd commented 5 months ago

I'm closing this for now, as we've got the stage 2 buildConfig merged into jink-dev. However, if there are features of your work that are missing in the merged version (important env var parameters perhaps), please let me know and we can schedule adding them. Thanks!

jhuttana commented 5 months ago

I'm closing this for now, as we've got the stage 2 buildConfig merged into jink-dev. However, if there are features of your work that are missing in the merged version (important env var parameters perhaps), please let me know and we can schedule adding them. Thanks!

Sure Jon Thank you