Skip to content

Commit ffc949d

Browse files
author
Jan Lieskovsky
committed
[CIAM-2881] Add a demo on how to rebuild the standard Red Hat Single Sign-On
7.5 container image to start using the latest version of IBM Semeru 11 Open Edition JDK (OpenJ9 JVM) instead of the default Red Hat OpenJDK 11 one. Also add a helper script to (re)generate the existing templates to start using the newly built image stream Also correct issues pointed out by Andrew Munro during PR review. Thanks, Andy! Moreover, add the existence of Registry Service Account, and installation of the default Red Hat Single Sign-On 7.5.X OpenShift image stream as requirements for the custom OpenShift build. Signed-off-by: Jan Lieskovsky <[email protected]>
1 parent 1471cc8 commit ffc949d

File tree

4 files changed

+380
-0
lines changed

4 files changed

+380
-0
lines changed

jdk/README.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
## Using Red Hat Single Sign-On 7.5 container images with alternative JDK
2+
3+
The Red Hat Single Sign-On 7.5 for OpenJDK container images use the [Red Hat OpenJDK 11](https://access.redhat.com/documentation/en-us/openjdk/11/html-single/getting_started_with_openjdk_11/index#openjdk-overview), a free and open source implementation of the Java Platform, Standard Edition (Java SE) by default.
4+
5+
To provide an illustrative example on how to install an alternative JDK and instruct the Red Hat Single Sign-On 7.5 container images to use it, the 'ibm-semeru-open-11-jdk' subdirectory contains a definition of Red Hat Single Sign-On 7.5 container file switching the JDK runtime to the latest available release of [IBM Semeru Runtime Open Edition Java 11 (LTS)](https://github.com/ibmruntimes/semeru11-binaries/releases/latest).
6+
7+
## Building the Red Hat Single Sign-On 7.5 container image with latest release of IBM Semeru 11 JDK Open Edition
8+
9+
You can build this example by creating a new build using OpenShift CLI (oc) tool. Specify:
10+
* The vanilla `rh-sso-7/sso75-openshift-rhel8` image stream to use as the builder,
11+
* The Docker build strategy to use for build execution, and
12+
* The Git repository, branch name and particular context directory within the repository as the source of the build
13+
14+
.Prerequisites
15+
16+
* Ensure you have [OpenShift CLI (oc) installed](https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/getting-started-cli.html#installing-openshift-cli)
17+
* Make sure you have [Registry Service Account](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html-single/red_hat_single_sign-on_for_openshift/index#image-streams-applications-templates) to access the secured Red Hat Registry *registry.redhat.io*. Be sure you can use the secret for pulling images for pods, and also for pushing and pulling build images. See the [Red Hat Container Registry Authentication](https://access.redhat.com/RegistryAuthentication) article for more information.
18+
* Moreover, assure you have [the Red Hat Single Sign-On 7.5.X OpenShift image stream installed](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html-single/red_hat_single_sign-on_for_openshift/index#image-streams-applications-templates) in the *openshift* project.
19+
20+
.Procedure
21+
22+
1. Ensure that you are logged in as a cluster administrator or a user with project administrator access to the global `openshift` project. Choose the following command based on your version of OpenShift Container Platform:
23+
24+
* If you are running an OpenShift Container Platform v3 based cluster instance on (some) of your master host(s), perform the following:
25+
26+
```
27+
$ oc login -u system:admin
28+
```
29+
30+
* If you are running an OpenShift Container Platform v4 based cluster instance, [log in to the CLI](https://docs.openshift.com/container-platform/latest/cli_reference/openshift_cli/getting-started-cli.html#cli-logging-in_cli-developer-commands) as the [kubeadmin](https://docs.openshift.com/container-platform/latest/authentication/remove-kubeadmin.html#understanding-kubeadmin_removing-kubeadmin) user:
31+
32+
```
33+
$ oc login -u kubeadmin -p password https://openshift.example.com:6443
34+
```
35+
36+
2. Execute the following command:
37+
38+
```
39+
$ oc new-build \
40+
--context-dir=jdk/ibm-semeru-open-11-jdk \
41+
--image-stream=openshift/sso75-openshift-rhel8:7.5 \
42+
--name=sso75-openshift-rhel8-ibm-semeru-11-jdk \
43+
--namespace=openshift \
44+
--strategy=docker \
45+
https://github.com/jboss-container-images/redhat-sso-7-openshift-image.git#sso75-dev
46+
```
47+
48+
When submitted, this command creates a new `sso75-openshift-rhel8-ibm-semeru-11-jdk` BuildConfig definition in the global `openshift` project and launches a build from it. Moreover, a new `sso75-openshift-rhel8-ibm-semeru-11-jdk` ImageStream is also created in the global `openshift` project.
49+
50+
## Acquiring OpenShift templates for the new Red Hat Single Sign-On 7.5 container `sso75-openshift-rhel8-ibm-semeru-11-jdk` image stream
51+
52+
You can obtain OpenShift templates for the newly produced `sso75-openshift-rhel8-ibm-semeru-11-jdk` image stream by performing the following modifications [to the standard templates available for the Red Hat Single Sign-On 7.5 container image](https://github.com/jboss-container-images/redhat-sso-7-openshift-image/tree/sso75-dev/templates):
53+
54+
* Change the default image stream name and image tag from `"sso75-openshift-rhel8:7.5"` to `"sso75-openshift-rhel8-ibm-semeru-11-jdk"`,
55+
56+
* Optinally add a custom suffix to the name of the original template later better to distinguish the newly created templates for IBM Semeru 11 JDK Open Edition from the original one. Alternatively, if **you just want to modify** [**the default Red Hat Single Sign-On 7.5 container image OpenShift templates**](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html-single/red_hat_single_sign-on_for_openshift#sso-templates) to start using the new `sso75-openshift-rhel8-ibm-semeru-11-jdk` image stream, then **define the custom suffix to be empty string**.
57+
58+
### Modifying the default Red Hat Single Sign-On 7.5 container image templates to use `"sso75-openshift-rhel8-ibm-semeru-11-jdk"` image stream
59+
60+
Use this option if you want to continue using the [**the default Red Hat Single Sign-On 7.5 container image OpenShift templates**](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html-single/red_hat_single_sign-on_for_openshift#sso-templates) with the new `sso75-openshift-rhel8-ibm-semeru-11-jdk` image stream.
61+
62+
.Prerequisites
63+
64+
* Ensure you have [the default OpenShift templates for Red Hat Single Sign-On 7.5 container image installed](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html-single/red_hat_single_sign-on_for_openshift/index#image-streams-applications-templates).
65+
66+
.Procedure
67+
68+
1. Set TEMPLATE\_SUFFIX environment variable to empty string and run the `acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh` helper script as follows:
69+
70+
```
71+
$ TEMPLATE_SUFFIX="" ./ibm-semeru-open-11-jdk/scripts/templates/acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh
72+
```
73+
74+
In this case the `./ibm-semeru-open-11-jdk/scripts/templates/acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh` script will just change the image stream name from `"sso75-openshift-rhel8:7.5"` to `"sso75-openshift-rhel8-ibm-semeru-11-jdk"` for each of the default Red Hat Single Sign-On 7.5 container image templates.
75+
76+
As a result, the output of the script looks as follows:
77+
78+
```
79+
$ TEMPLATE_SUFFIX="" ./ibm-semeru-open-11-jdk/scripts/templates/acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh
80+
template.template.openshift.io "sso75-https" deleted
81+
template.template.openshift.io/sso75-https replaced
82+
template.template.openshift.io "sso75-postgresql" deleted
83+
template.template.openshift.io/sso75-postgresql replaced
84+
template.template.openshift.io "sso75-postgresql-persistent" deleted
85+
template.template.openshift.io/sso75-postgresql-persistent replaced
86+
template.template.openshift.io "sso75-x509-https" deleted
87+
template.template.openshift.io/sso75-x509-https replaced
88+
template.template.openshift.io "sso75-x509-postgresql" deleted
89+
template.template.openshift.io/sso75-x509-postgresql-persistent replaced
90+
```
91+
92+
### Generating IBM Semeru 11 JDK Open Edition specific Red Hat Single Sign-On 7.5 container image templates
93+
94+
Use this option if you want a new template with custom suffix in its name to be created for each of the default RH-SSO templates using the `sso75-openshift-rhel8-ibm-semeru-11-jdk` image stream.
95+
96+
.Prerequisites
97+
98+
* Ensure you have [the default OpenShift templates for Red Hat Single Sign-On 7.5 container image installed](https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html-single/red_hat_single_sign-on_for_openshift/index#image-streams-applications-templates).
99+
100+
101+
.Procedure
102+
103+
1. Set TEMPLATE\_SUFFIX environment variable to contain the desired suffix for newly generated templates, for example `"-ibm-semeru-11-jdk"`. Then run the `acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh` helper script as follows:
104+
105+
106+
```
107+
$ TEMPLATE_SUFFIX="-ibm-semeru-11-jdk" ./ibm-semeru-open-11-jdk/scripts/templates/acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh
108+
```
109+
110+
In this case the `./ibm-semeru-open-11-jdk/scripts/templates/acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh` script:
111+
112+
1. First creates a Semeru JDK 11 counterpart copy of the particular default template with specified template suffix appended to the file name of the original template,
113+
2. Updates the `.metadata.name` field of that template copy to match the new name of the template,
114+
3. Replaces the name of the default image stream in the `sso` DeploymentConfig definition of the template with `sso75-openshift-rhel8-ibm-semeru-11-jdk` image stream,
115+
4. Finally, recreates the template with the new name using the updated image stream in the global `openshift` project.
116+
117+
As a result, the output of the script looks as follows:
118+
119+
```
120+
$ TEMPLATE_SUFFIX="-ibm-semeru-11-jdk" ./ibm-semeru-open-11-jdk/scripts/templates/acquire-ibm-semeru-open-11-jdk-rh-sso-templates.sh
121+
template.template.openshift.io "sso75-https-ibm-semeru-11-jdk" deleted
122+
template.template.openshift.io/sso75-https-ibm-semeru-11-jdk replaced
123+
template.template.openshift.io "sso75-postgresql-ibm-semeru-11-jdk" deleted
124+
template.template.openshift.io/sso75-postgresql-ibm-semeru-11-jdk replaced
125+
template.template.openshift.io "sso75-postgresql-persistent-ibm-semeru-11-jdk" deleted
126+
template.template.openshift.io/sso75-postgresql-persistent-ibm-semeru-11-jdk replaced
127+
template.template.openshift.io "sso75-x509-https-ibm-semeru-11-jdk" deleted
128+
template.template.openshift.io/sso75-x509-https-ibm-semeru-11-jdk replaced
129+
template.template.openshift.io "sso75-x509-postgresql-persistent-ibm-semeru-11-jdk" deleted
130+
template.template.openshift.io/sso75-x509-postgresql-persistent-ibm-semeru-11-jdk replaced
131+
```
132+
133+
## Deploying Red Hat Single Sign-On 7.5 container image with latest release of IBM Semeru 11 JDK Open Edition
134+
135+
You can deploy Red Hat Single Sign-On 7.5 container image using latest IBM Semeru 11 JDK Open Edition as usual. The only differing step is the name of the template to use depending if default templates were overwritten, or new ones were generated.
136+
137+
.Procedure
138+
139+
1. Create a `semeru-demo` project:
140+
141+
```
142+
$ oc new-project semeru-demo
143+
```
144+
145+
2. Create a new application, using the Red Hat Single Sign-On 7.5 container image with latest release of IBM Semeru 11 JDK Open Edition as usual. For example, run:
146+
147+
```
148+
$ oc new-app --template=sso75-x509-https
149+
```
150+
151+
if you previously modified the default `sso75-x509-https` template to start using the `sso75-openshift-rhel8-ibm-semeru-11-jdk`, or run
152+
153+
```
154+
$ oc new-app --template=sso75-x509-https-ibm-semeru-11-jdk
155+
```
156+
157+
if you previously generated IBM Semeru 11 JDK Open Edition templates using the `-ibm-semeru-11-jdk` suffix and want to deploy the IBM Semeru counterpart of `sso75-x509-https` template.
158+
159+
## References
160+
161+
* [IBM Semeru Runtimes Open Edition for Java 11 binaries GitHub repository](https://github.com/ibmruntimes/semeru11-binaries)
162+
* [IBM Semeru Runtimes main GitHub repository](https://github.com/ibmruntimes/Semeru-Runtimes)
163+
* [IBM Semeru Runtimes website](https://developer.ibm.com/languages/java/semeru-runtimes)
164+
* [IBM Semeru Runtimes support page](https://www.ibm.com/support/pages/semeru-runtimes-support/)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM registry.redhat.io/rh-sso-7/sso75-openshift-rhel8:latest
2+
# Define the (buildtime) user
3+
USER root
4+
# Copy the helper container image script
5+
COPY scripts/image /tmp/scripts
6+
# Make IBM Semeru 11 JDK the default JDK
7+
RUN [ "sh", "-x", "/tmp/scripts/make-ibm-semeru-open-11-jdk-the-default-jdk.sh" ]
8+
# Remove helper scripts
9+
RUN [ ! -d "/tmp/scripts" ] || rm -rf "/tmp/scripts"
10+
# Define the (runtime) user
11+
USER jboss
12+
# Define the (runtime) working directory
13+
WORKDIR /home/jboss
14+
# Define the default run cmd
15+
CMD ["/opt/eap/bin/openshift-launch.sh"]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
# Install the 'dejavu-sans-fonts' IBM Semeru 11 JDK RPM dependency first
6+
# Moreover, install also 'jq' later to parse the release info JSON file of
7+
# latest IBM Semeru 11 JDK GitHub tag (release)
8+
microdnf -y install dejavu-sans-fonts jq && microdnf clean all
9+
10+
# Given the architecture
11+
# shellcheck disable=SC2155
12+
readonly ARCH=$(uname -i)
13+
14+
# Get the release info JSON file for latest IBM Semeru 11 JDK tag from GitHub
15+
# shellcheck disable=SC2155
16+
readonly LATEST_SEMERU_11_JDK_RELEASE_JSON=$(
17+
curl --header "Accept: application/vnd.github.v3+json" --show-error --silent \
18+
"https://api.github.com/repos/ibmruntimes/semeru11-binaries/releases/latest"
19+
)
20+
21+
# Out of all assets published for latest IBM Semeru 11 JDK release select just
22+
# the download URL of RPM package specific for this architecture
23+
# shellcheck disable=SC2155
24+
readonly LATEST_SEMERU_11_JDK_RPM=$(
25+
# Return URL of that asset from release info, having 'content_type' set to
26+
# 'application/x-rpm', ending with '${ARCH}.rpm}' and not being a JRE RPM
27+
jq '.assets[]
28+
| select(.content_type == "application/x-rpm")
29+
| .browser_download_url
30+
| select(endswith("'"${ARCH}"'.rpm") and (contains("jre") | not))' \
31+
<<< "${LATEST_SEMERU_11_JDK_RELEASE_JSON[@]}" | tr -d '"'
32+
)
33+
34+
# Import the IBM Semeru Runtimes public GPG key
35+
# URL below from https://www.ibm.com/support/pages/semeru-runtimes-verification/
36+
# section "RPM Package Manager packages (.rpm)"
37+
rpm --import "https://public.dhe.ibm.com/ibmdl/export/pub/systems/cloud/runtimes/java/certificates/ibm-semeru-public-GPGkey.pgp"
38+
39+
# Download the latest IBM Semeru 11 JDK Open Edition RPM
40+
curl -OLJ --show-error --silent "${LATEST_SEMERU_11_JDK_RPM}"
41+
42+
# Verify the signatures & digests of the downloaded RPM are correct
43+
rpmkeys -Kv "./$(basename "${LATEST_SEMERU_11_JDK_RPM}")"
44+
45+
# If so, install the RPM
46+
rpm -i "./$(basename "${LATEST_SEMERU_11_JDK_RPM}")"
47+
48+
# Make latest IBM Semeru 11 JDK the default JDK
49+
alternatives --set java /usr/lib/jvm/ibm-semeru-open-11-jdk/bin/java
50+
alternatives --set javac /usr/lib/jvm/ibm-semeru-open-11-jdk/bin/javac
51+
export JAVA_SECURITY_FILE=/usr/lib/jvm/ibm-semeru-open-11-jdk/conf/security/java.security
52+
export JAVA_HOME=/usr/lib/jvm/ibm-semeru-open-11-jdk
53+
54+
# Remove the (formerly default) OpenJDK 11 RPM packages
55+
microdnf remove java-11-openjdk{,-devel,-headless}

0 commit comments

Comments
 (0)