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> コマンドを実行して、サービスアカウントが SharedSecret CR を使用できるかどうか、およびサービスアカウントが namespace にリストされるかどうかを確認する。
注記

最後の 2 つの前提条件を満たせない場合は、クラスター管理者に必要な RBAC 権限を設定してもらうことで、サービスアカウントに SharedSecret CR の使用を許可できるようになります。

手順

  1. 次のコマンドを実行して、クラスターのエンタイトルメントシークレットを含む 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
  2. 次の設定例を使用して、SharedSecret オブジェクトにアクセスする権限を付与する ClusterRole オブジェクトを作成します。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: use-share-etc-pki-entitlement 
    1
    
    rules:
      - apiGroups:
          - sharedresource.openshift.io
        resources:
          - sharedsecrets
        resourceNames:
          - etc-pki-entitlement
        verbs:
          - use
    1
    ClusterRole CR の名前。
  3. Shared Resources CSI Driver に SharedSecret オブジェクトにアクセスする権限を付与する Role および RoleBinding オブジェクトを作成します。

    Role オブジェクトの例

    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: share-etc-pki-entitlement 
    1
    
      namespace: openshift-config-managed
    rules:
      - apiGroups:
          - ""
        resources:
          - secrets
        resourceNames:
          - etc-pki-entitlement
        verbs:
          - get
          - list
          - watch

    1
    Role CR の名前。

    RoleBinding オブジェクトの例

    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: share-etc-pki-entitlement 
    1
    
      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-builds 
    2

    1
    RoleBinding CR の名前。
    2
    openshift-builds がインストールされている namespace の名前。
  4. ビルドが実行される namespace に、builder および pipeline サービスアカウントの RoleBinding オブジェクトを作成します。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: use-share-etc-pki-entitlement 
    1
    
    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 サービスアカウントの RoleBinding CR の名前。
    注記

    SharedSecret オブジェクトを使用するサービスアカウントは、OpenShift コントローラーによって作成および管理されます。

  5. 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: true 
    1
    
          volumeAttributes:
            sharedSecret: <sharedsecret_object_name> 
    2
    
        name: etc-pki-entitlement
      output:
        image: <output_image_location> 
    3
    
    EOF
    1
    ビルドで共有リソースをマウントするには、readOnlytrue に設定する必要があります。
    2
    <sharedsecret_object_name> は、ビルドに含める SharedSecret オブジェクトの名前に置き換えます。
    3
    <output_image_location> は、ビルドしたイメージをプッシュする場所に置き換えます。
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る