Skip to content

Commit f7fb0fb

Browse files
Merge pull request #71994 from joaedwar/23115-updates-subscriptions
OCPBUGS-23115:Clarify instructions for builds
2 parents b4bde06 + 4b1b09c commit f7fb0fb

7 files changed

+97
-140
lines changed

cicd/builds/running-entitled-builds.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include::_attributes/common-attributes.adoc[]
77
toc::[]
88

99
[role="_abstract"]
10-
Use the following sections to run entitled builds on {product-title}.
10+
Use the following sections to install Red Hat subscription content within {product-title} builds.
1111

1212
include::modules/builds-create-imagestreamtag.adoc[leveloffset=+1]
1313

modules/builds-create-imagestreamtag.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
[id="builds-create-imagestreamtag_{context}"]
77
= Creating an image stream tag for the Red Hat Universal Base Image
88

9-
To use Red Hat subscriptions within a build, you create an image stream tag to reference the Universal Base Image (UBI).
9+
To install {op-system-base-full} packages within a build, you can create an image stream tag to reference the Red Hat Universal Base Image (UBI).
1010

11-
To make the UBI available *in every project* in the cluster, you add the image stream tag to the `openshift` namespace. Otherwise, to make it available *in a specific project*, you add the image stream tag to that project.
11+
To make the UBI available *in every project* in the cluster, add the image stream tag to the `openshift` namespace. Otherwise, to make it available *in a specific project*, add the image stream tag to that project.
1212

13-
The benefit of using image stream tags this way is that doing so grants access to the UBI based on the `registry.redhat.io` credentials in the install pull secret without exposing the pull secret to other users. This is more convenient than requiring each developer to install pull secrets with `registry.redhat.io` credentials in each project.
13+
Image stream tags grant access to the UBI by using the `registry.redhat.io` credentials that are present in the install pull secret, without exposing the pull secret to other users. This method is more convenient than requiring each developer to install pull secrets with `registry.redhat.io` credentials in each project.
1414

1515
.Procedure
1616

1717
* To create an `ImageStreamTag` in the `openshift` namespace, so it is available to developers in all projects, enter:
1818
+
1919
[source,terminal]
2020
----
21-
$ oc tag --source=docker registry.redhat.io/ubi9/ubi:latest ubi:latest -n openshift
21+
$ oc tag --source=docker registry.redhat.io/ubi9/ubi:latest ubi9:latest -n openshift
2222
----
2323
+
2424
[TIP]
@@ -29,7 +29,7 @@ You can alternatively apply the following YAML to create an `ImageStreamTag` in
2929
apiVersion: image.openshift.io/v1
3030
kind: ImageStream
3131
metadata:
32-
name: ubi
32+
name: ubi9
3333
namespace: openshift
3434
spec:
3535
tags:
@@ -57,7 +57,7 @@ You can alternatively apply the following YAML to create an `ImageStreamTag` in
5757
apiVersion: image.openshift.io/v1
5858
kind: ImageStream
5959
metadata:
60-
name: ubi
60+
name: ubi9
6161
spec:
6262
tags:
6363
- from:
Lines changed: 50 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
:_mod-docs-content-type: PROCEDURE
22
[id="builds-running-entitled-builds-with-sharedsecret-objects_{context}"]
3-
= Running entitled builds using SharedSecret objects
3+
= Running builds using SharedSecret objects
44

5-
You can configure and perform a build in one namespace that securely uses RHEL entitlements from a `Secret` object in another namespace.
5+
You can use a `SharedSecret` object to securely access the entitlement keys of a cluster in builds.
66

7-
You can still access RHEL entitlements from OpenShift Builds by creating a `Secret` object with your subscription credentials in the same namespace as your `Build` object. However, now, in {product-title} 4.10 and later, you can access your credentials and certificates from a `Secret` object in one of the {product-title} system namespaces. You run entitled builds with a CSI volume mount of a `SharedSecret` custom resource (CR) instance that references the `Secret` object.
7+
The `SharedSecret` object allows you to share and synchronize secrets across namespaces.
88

9-
This procedure relies on the newly introduced Shared Resources CSI Driver feature, which you can use to declare CSI Volume mounts in {product-title} Builds. It also relies on the {product-title} Insights Operator.
10-
11-
:FeatureName: Managing machines with the Cluster API
9+
:FeatureName: Shared Resource CSI Driver
1210
include::snippets/technology-preview.adoc[]
1311

14-
The Shared Resources CSI Driver feature also belongs to the `TechPreviewNoUpgrade` feature set, which is a subset of the current Technology Preview features. You can enable the `TechPreviewNoUpgrade` feature set on test clusters, where you can fully test them while leaving the features disabled on production clusters. Enabling this feature set cannot be undone and prevents minor version updates. This feature set is not recommended on production clusters. See "Enabling Technology Preview features using feature gates" in the following "Additional resources" section.
15-
1612
.Prerequisites
1713

18-
* You have enabled the `TechPreviewNoUpgrade` feature set by using the feature gates.
19-
* You have a `SharedSecret` custom resource (CR) instance that references the `Secret` object where the Insights Operator stores the subscription credentials.
14+
* You have enabled the `TechPreviewNoUpgrade` feature set by using the feature gates. For more information, see xref:../../nodes/clusters/nodes-cluster-enabling-features.adoc#nodes-cluster-enabling[Enabling features using feature gates].
2015
* You must have permission to perform the following actions:
2116
** Create build configs and start builds.
2217
** Discover which `SharedSecret` CR instances are available by entering the `oc get sharedsecrets` command and getting a non-empty list back.
@@ -29,169 +24,105 @@ If neither of the last two prerequisites in this list are met, establish, or ask
2924

3025
.Procedure
3126

32-
. Grant the `builder` service account RBAC permissions to use the `SharedSecret` CR instance by using `oc apply` with YAML content:
27+
. Use `oc apply` to create a `SharedSecret` object instance with the cluster's entitlement secret.
3328
+
34-
[NOTE]
29+
[IMPORTANT]
3530
====
36-
Currently, `kubectl` and `oc` have hard-coded special case logic restricting the `use` verb to roles centered around pod security. Therefore, you cannot use `oc create role ...` to create the role needed for consuming `SharedSecret` CR instances.
31+
You must have cluster administrator permissions to create `SharedSecret` objects.
3732
====
3833
+
3934
.Example `oc apply -f` command with YAML `Role` object definition
4035
[source,terminal]
4136
----
4237
$ oc apply -f - <<EOF
38+
kind: SharedSecret
39+
apiVersion: sharedresource.openshift.io/v1alpha1
40+
metadata:
41+
name: etc-pki-entitlement
42+
spec:
43+
secretRef:
44+
name: etc-pki-entitlement
45+
namespace: openshift-config-managed
46+
EOF
47+
----
48+
49+
. Create a role to grant the `builder` service account permission to access the `SharedSecret` object:
50+
+
51+
.Example `oc apply -f` command
52+
[source,terminal]
53+
----
54+
$ oc apply -f - <<EOF
4355
apiVersion: rbac.authorization.k8s.io/v1
4456
kind: Role
4557
metadata:
46-
name: shared-resource-my-share
47-
namespace: my-namespace
58+
name: builder-etc-pki-entitlement
59+
namespace: build-namespace
4860
rules:
4961
- apiGroups:
5062
- sharedresource.openshift.io
5163
resources:
5264
- sharedsecrets
5365
resourceNames:
54-
- my-share
66+
- etc-pki-entitlement
5567
verbs:
5668
- use
5769
EOF
5870
----
5971

60-
. Create the `RoleBinding` associated with the role by using the `oc` command:
72+
. Create a `RoleBinding` object that grants the `builder` service account permission to access the `SharedSecret` object by running the following command:
6173
+
6274
.Example `oc create rolebinding` command
6375
[source,terminal]
6476
----
65-
$ oc create rolebinding shared-resource-my-share --role=shared-resource-my-share --serviceaccount=my-namespace:builder
77+
$ oc create rolebinding builder-etc-pki-entitlement --role=builder-etc-pki-entitlement --serviceaccount=build-namespace:builder
6678
----
6779

68-
. Create a `BuildConfig` object that accesses the RHEL entitlements.
80+
. Add the entitlement secret to your `BuildConfig` object by using a CSI volume mount:
6981
+
7082
.Example YAML `BuildConfig` object definition
7183
[source,yaml]
7284
----
7385
apiVersion: build.openshift.io/v1
7486
kind: BuildConfig
7587
metadata:
76-
name: my-csi-bc
77-
namespace: my-csi-app-namespace
88+
name: uid-wrapper-rhel9
89+
namespace: build-namespace
7890
spec:
7991
runPolicy: Serial
8092
source:
8193
dockerfile: |
8294
FROM registry.redhat.io/ubi9/ubi:latest
83-
RUN ls -la /etc/pki/entitlement
84-
RUN rm /etc/rhsm-host
85-
RUN yum repolist --disablerepo=*
86-
RUN subscription-manager repos --enable rhocp-4.9-for-rhel-8-x86_64-rpms
87-
RUN yum -y update
88-
RUN yum install -y openshift-clients.x86_64
95+
RUN rm -rf /etc/rhsm-host <1>
96+
RUN yum --enablerepo=codeready-builder-for-rhel-9-x86_64-rpms install \ <2>
97+
nss_wrapper \
98+
uid_wrapper -y && \
99+
yum clean all -y
100+
RUN ln -s /run/secrets/rhsm /etc/rhsm-host <3>
89101
strategy:
90102
type: Docker
91103
dockerStrategy:
92104
volumes:
93105
- mounts:
94106
- destinationPath: "/etc/pki/entitlement"
95-
name: my-csi-shared-secret
107+
name: etc-pki-entitlement
96108
source:
97109
csi:
98110
driver: csi.sharedresource.openshift.io
99-
readOnly: true
111+
readOnly: true <4>
100112
volumeAttributes:
101-
sharedSecret: my-share-bc
113+
sharedSecret: etc-pki-entitlement <5>
102114
type: CSI
103115
----
104-
105-
. Start a build from the `BuildConfig` object and follow the logs with the `oc` command.
106116
+
107-
.Example oc start-build command
108-
[source,terminal]
109-
----
110-
$ oc start-build my-csi-bc -F
111-
----
117+
<1> You must include the command to remove the `/etc/rhsm-host` directory and all its contents in the Dockerfile before executing any `yum` or `dnf` commands.
118+
<2> Use the link:https://access.redhat.com/downloads/content/package-browser[Red Hat Package Browser] to find the correct repositories for your installed packages.
119+
<3> You must restore the `/etc/rhsm-host` symbolic link to keep your image compatible with other Red Hat container images.
120+
<4> You must set `readOnly` to `true` to mount the shared resource in the build.
121+
<5> Reference the name of the `SharedSecret` object to include it in the build.
122+
123+
. Start a build from the `BuildConfig` object and follow the logs using the `oc` command.
112124
+
113-
.Example output from the oc start-build command
114-
[%collapsible]
115-
====
116-
[NOTE]
117-
=====
118-
Some sections of the following output have been replaced with `...`
119-
=====
120125
[source,terminal]
121126
----
122-
build.build.openshift.io/my-csi-bc-1 started
123-
Caching blobs under "/var/cache/blobs".
124-
125-
Pulling image registry.redhat.io/ubi9/ubi:latest ...
126-
Trying to pull registry.redhat.io/ubi9/ubi:latest...
127-
Getting image source signatures
128-
Copying blob sha256:5dcbdc60ea6b60326f98e2b49d6ebcb7771df4b70c6297ddf2d7dede6692df6e
129-
Copying blob sha256:8671113e1c57d3106acaef2383f9bbfe1c45a26eacb03ec82786a494e15956c3
130-
Copying config sha256:b81e86a2cb9a001916dc4697d7ed4777a60f757f0b8dcc2c4d8df42f2f7edb3a
131-
Writing manifest to image destination
132-
Storing signatures
133-
Adding transient rw bind mount for /run/secrets/rhsm
134-
STEP 1/9: FROM registry.redhat.io/ubi9/ubi:latest
135-
STEP 2/9: RUN ls -la /etc/pki/entitlement
136-
total 360
137-
drwxrwxrwt. 2 root root 80 Feb 3 20:28 .
138-
drwxr-xr-x. 10 root root 154 Jan 27 15:53 ..
139-
-rw-r--r--. 1 root root 3243 Feb 3 20:28 entitlement-key.pem
140-
-rw-r--r--. 1 root root 362540 Feb 3 20:28 entitlement.pem
141-
time="2022-02-03T20:28:32Z" level=warning msg="Adding metacopy option, configured globally"
142-
--> 1ef7c6d8c1a
143-
STEP 3/9: RUN rm /etc/rhsm-host
144-
time="2022-02-03T20:28:33Z" level=warning msg="Adding metacopy option, configured globally"
145-
--> b1c61f88b39
146-
STEP 4/9: RUN yum repolist --disablerepo=*
147-
Updating Subscription Management repositories.
148-
149-
150-
...
151-
152-
--> b067f1d63eb
153-
STEP 5/9: RUN subscription-manager repos --enable rhocp-4.9-for-rhel-8-x86_64-rpms
154-
Repository 'rhocp-4.9-for-rhel-8-x86_64-rpms' is enabled for this system.
155-
time="2022-02-03T20:28:40Z" level=warning msg="Adding metacopy option, configured globally"
156-
--> 03927607ebd
157-
STEP 6/9: RUN yum -y update
158-
Updating Subscription Management repositories.
159-
160-
...
161-
162-
Upgraded:
163-
systemd-239-51.el8_5.3.x86_64 systemd-libs-239-51.el8_5.3.x86_64
164-
systemd-pam-239-51.el8_5.3.x86_64
165-
Installed:
166-
diffutils-3.6-6.el8.x86_64 libxkbcommon-0.9.1-1.el8.x86_64
167-
xkeyboard-config-2.28-1.el8.noarch
168-
169-
Complete!
170-
time="2022-02-03T20:29:05Z" level=warning msg="Adding metacopy option, configured globally"
171-
--> db57e92ff63
172-
STEP 7/9: RUN yum install -y openshift-clients.x86_64
173-
Updating Subscription Management repositories.
174-
175-
...
176-
177-
Installed:
178-
bash-completion-1:2.7-5.el8.noarch
179-
libpkgconf-1.4.2-1.el8.x86_64
180-
openshift-clients-4.9.0-202201211735.p0.g3f16530.assembly.stream.el8.x86_64
181-
pkgconf-1.4.2-1.el8.x86_64
182-
pkgconf-m4-1.4.2-1.el8.noarch
183-
pkgconf-pkg-config-1.4.2-1.el8.x86_64
184-
185-
Complete!
186-
time="2022-02-03T20:29:19Z" level=warning msg="Adding metacopy option, configured globally"
187-
--> 609507b059e
188-
STEP 8/9: ENV "OPENSHIFT_BUILD_NAME"="my-csi-bc-1" "OPENSHIFT_BUILD_NAMESPACE"="my-csi-app-namespace"
189-
--> cab2da3efc4
190-
STEP 9/9: LABEL "io.openshift.build.name"="my-csi-bc-1" "io.openshift.build.namespace"="my-csi-app-namespace"
191-
COMMIT temp.builder.openshift.io/my-csi-app-namespace/my-csi-bc-1:edfe12ca
192-
--> 821b582320b
193-
Successfully tagged temp.builder.openshift.io/my-csi-app-namespace/my-csi-bc-1:edfe12ca
194-
821b582320b41f1d7bab4001395133f86fa9cc99cc0b2b64c5a53f2b6750db91
195-
Build complete, no image push requested
127+
$ oc start-build uid-wrapper-rhel9 -n build-namespace -F
196128
----
197-
====

modules/builds-source-input-satellite-config.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ strategy:
4343
dockerStrategy:
4444
from:
4545
kind: ImageStreamTag
46-
name: ubi:latest
46+
name: ubi9:latest
4747
volumes:
4848
- name: yum-repos-d
4949
mounts:

modules/builds-source-secrets-entitlements.adoc

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,32 @@ Builds that use Red Hat subscriptions to install content must include the entitl
1010

1111
.Prerequisites
1212

13-
You must have access to Red Hat entitlements through your subscription. The entitlement secret is automatically created by the Insights Operator.
13+
You must have access to {op-system-base-full} package repositories through your subscription.
1414

15+
The entitlement secret to access these repositories is automatically created by the Insights Operator when your cluster is subscribed.
1516

16-
[TIP]
17+
[IMPORTANT]
1718
====
18-
When you perform an Entitlement Build using {op-system-base-full} 7, you must have the following instructions in your Dockerfile before you run any `yum` commands:
19+
You must be a cluster administrator or have permission to access secrets in the `openshift-config-managed` project.
20+
====
21+
22+
.Procedure
1923

24+
. Copy the entitlement secret from the `openshift-config-managed` namespace to the build's namespace:
25+
+
2026
[source,terminal]
2127
----
22-
RUN rm /etc/rhsm-host
28+
$ cat << EOF > secret-template.txt
29+
kind: Secret
30+
apiVersion: v1
31+
metadata:
32+
name: etc-pki-entitlement
33+
type: Opaque
34+
data: {{ range \$key, \$value := .data }}
35+
{{ \$key }}: {{ \$value }} {{ end }}
36+
EOF
37+
$ oc get secret etc-pki-entitlement -n openshift-config-managed -o=go-template-file --template=secret-template.txt | oc apply -f -
2338
----
24-
====
25-
26-
.Procedure
2739

2840
. Add the etc-pki-entitlement secret as a build volume in the build configuration’s Docker strategy:
2941
+
@@ -33,7 +45,7 @@ strategy:
3345
dockerStrategy:
3446
from:
3547
kind: ImageStreamTag
36-
name: ubi:latest
48+
name: ubi9:latest
3749
volumes:
3850
- name: etc-pki-entitlement
3951
mounts:

modules/builds-strategy-docker-entitled-satellite.adoc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ Use the following as an example Dockerfile to install content with Satellite:
1818
[source,terminal]
1919
----
2020
FROM registry.redhat.io/ubi9/ubi:latest
21-
RUN dnf search kernel-devel --showduplicates && \
22-
dnf install -y kernel-devel
21+
RUN rm -rf /etc/rhsm-host <1>
22+
RUN yum --enablerepo=codeready-builder-for-rhel-9-x86_64-rpms install \ <2>
23+
nss_wrapper \
24+
uid_wrapper -y && \
25+
yum clean all -y
26+
RUN ln -s /run/secrets/rhsm /etc/rhsm-host <3>
2327
----
28+
<1> You must include the command to remove the `/etc/rhsm-host` directory and all its contents in your Dockerfile before executing any `yum` or `dnf` commands.
29+
<2> Contact your Satellite system administrator to find the correct repositories for the build's installed packages.
30+
<3> You must restore the `/etc/rhsm-host` symbolic link to keep your image compatible with other Red Hat container images.

modules/builds-strategy-docker-entitled-subman.adoc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[id="builds-strategy-docker-entitled-subman_{context}"]
77
= Docker builds using Subscription Manager
88

9-
Docker strategy builds can use the Subscription Manager to install subscription content.
9+
Docker strategy builds can use `yum` or `dnf` to install additional {op-system-base-full} packages.
1010

1111
.Prerequisites
1212

@@ -19,6 +19,13 @@ Use the following as an example Dockerfile to install content with the Subscript
1919
[source,terminal]
2020
----
2121
FROM registry.redhat.io/ubi9/ubi:latest
22-
RUN dnf search kernel-devel --showduplicates && \
23-
dnf install -y kernel-devel
22+
RUN rm -rf /etc/rhsm-host <1>
23+
RUN yum --enablerepo=codeready-builder-for-rhel-9-x86_64-rpms install \ <2>
24+
nss_wrapper \
25+
uid_wrapper -y && \
26+
yum clean all -y
27+
RUN ln -s /run/secrets/rhsm /etc/rhsm-host <3>
2428
----
29+
<1> You must include the command to remove the `/etc/rhsm-host` directory and all its contents in your Dockerfile before executing any `yum` or `dnf` commands.
30+
<2> Use the link:https://access.redhat.com/downloads/content/package-browser[Red Hat Package Browser] to find the correct repositories for your installed packages.
31+
<3> You must restore the `/etc/rhsm-host` symbolic link to keep your image compatible with other Red Hat container images.

0 commit comments

Comments
 (0)