1.3. RHEL エンタイトルメントを使用したイメージのビルド
Red Hat Enterprise Linux (RHEL) エンタイトルメントをお持ちの場合は、Insights Operator が Simple Content Access (SCA) 機能を使用してエンタイトルメントキーを自動的に管理します。SCA を使用すると、RHEL システムがサブスクリプションコンテンツにアクセスできるため、エンタイトルメントキーの手動管理が不要になります。Insights Operator は、SCA のエンタイトルメントキーをインポートし、openshift-config-managed namespace の etc-pki-entitlement という名前のシークレットに保存します。
以前は、クラスター管理者が etc-pki-entitlement シークレットを必要な namespace に手動でコピーしていました。OpenShift Container Platform 4.10 以降、builds for Red Hat OpenShift は、Shared Resource Container Storage Interface (CSI) Driver Operator を使用して、openshift-config-managed namespace の etc-pki-entitlement シークレットを、他の namespace と共有できます。
1.3.1. namespace 間での RHEL エンタイトルメントの共有 リンクのコピーリンクがクリップボードにコピーされました!
SharedSecret オブジェクトを使用すると、クラスターの RHEL エンタイトルメントキーを、Builds の namespace 間でセキュアに共有および同期できます。
前提条件
次の操作を実行するための権限がある。
-
SharedSecretオブジェクトを作成する。 - ビルド設定を作成し、ビルドを開始する。
-
oc get sharedsecretsコマンドを実行して、使用可能なSharedSecretカスタムリソース (CR) インスタンスを検出する。 -
oc adm policy who-can use <sharedsecret_identifier>コマンドを実行して、サービスアカウントがSharedSecretCR を使用できるかどうか、およびサービスアカウントが namespace にリストされるかどうかを確認する。
-
最後の 2 つの前提条件を満たせない場合は、クラスター管理者に必要な RBAC 権限を設定してもらうことで、サービスアカウントに SharedSecret CR の使用を許可できるようになります。
手順
次のコマンドを実行して、クラスターのエンタイトルメントシークレットを含む
SharedSecretオブジェクトインスタンスを作成します。$ oc apply -f -<<EOF apiVersion: sharedresource.openshift.io/v1alpha1 kind: SharedSecret metadata: name: etc-pki-entitlement spec: secretRef: name: etc-pki-entitlement namespace: openshift-config-managed EOF次の設定例を使用して、
SharedSecretオブジェクトにアクセスする権限を付与するClusterRoleオブジェクトを作成します。apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: use-share-etc-pki-entitlement1 rules: - apiGroups: - sharedresource.openshift.io resources: - sharedsecrets resourceNames: - etc-pki-entitlement verbs: - use- 1
ClusterRoleCR の名前。
Shared Resources CSI Driver に
SharedSecretオブジェクトにアクセスする権限を付与するRoleおよびRoleBindingオブジェクトを作成します。Roleオブジェクトの例apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: share-etc-pki-entitlement1 namespace: openshift-config-managed rules: - apiGroups: - "" resources: - secrets resourceNames: - etc-pki-entitlement verbs: - get - list - watch- 1
RoleCR の名前。
RoleBindingオブジェクトの例apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: share-etc-pki-entitlement1 namespace: openshift-config-managed roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: share-etc-pki-entitlement subjects: - kind: ServiceAccount name: csi-driver-shared-resource namespace: openshift-builds2 ビルドが実行される namespace に、
builderおよびpipelineサービスアカウントのRoleBindingオブジェクトを作成します。apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: use-share-etc-pki-entitlement1 roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: use-share-etc-pki-entitlement subjects: - kind: ServiceAccount name: pipeline - kind: ServiceAccount name: builder- 1
builderおよびpipelineサービスアカウントのRoleBindingCR の名前。
注記SharedSecretオブジェクトを使用するサービスアカウントは、OpenShift コントローラーによって作成および管理されます。buildahビルドストラテジーを使用してSharedSecretオブジェクトをマウントします。以下の例を参照してください。$ oc apply -f -<<EOF apiVersion: shipwright.io/v1beta1 kind: Build metadata: name: buildah-rhel spec: source: type: Git git: url: https://github.com/redhat-openshift-builds/samples contextDir: buildah-build strategy: name: buildah kind: ClusterBuildStrategy paramValues: - name: dockerfile value: DockerFile volumes: - csi: driver: csi.sharedresource.openshift.io readOnly: true1 volumeAttributes: sharedSecret: <sharedsecret_object_name>2 name: etc-pki-entitlement output: image: <output_image_location>3 EOF