検索

5.3. 共有リソース CSI ドライバー Operator を使用してシークレットを共有することによる Red Hat エンタイトルメントの使用

download PDF

Shared Resources Container Storage Interface (CSI) Driver Operator を使用して、openshift-config-managed namespace から他の namespace への etc-pki-entitlement シークレットの共有を設定できます。次に、Buildah タスクにこのシークレットを使用するようにパイプラインを設定できます。

前提条件

  • クラスター管理者のパーミッションを持つユーザーとして oc コマンドラインユーティリティーを使用して、OpenShift Container Platform クラスターにログインしている。
  • OpenShift Container Platform クラスターで Shared Resources CSI Driver Operator を有効にしている。

手順

  1. 次のコマンドを実行して、etc-pki-entitlement シークレットを共有するための SharedSecret カスタムリソース (CR) を作成します。

    $ oc apply -f - <<EOF
    apiVersion: sharedresource.openshift.io/v1alpha1
    kind: SharedSecret
    metadata:
      name: shared-rhel-entitlement
    spec:
      secretRef:
        name: etc-pki-entitlement
        namespace: openshift-config-managed
    EOF
  2. 次のコマンドを実行して、共有シークレットへのアクセスを許可する RBAC ロールを作成します。

    $ oc apply -f - <<EOF
    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: shared-resource-rhel-entitlement
      namespace: <pipeline_namespace> 1
    rules:
      - apiGroups:
          - sharedresource.openshift.io
        resources:
          - sharedsecrets
        resourceNames:
          - shared-rhel-entitlement
        verbs:
          - use
    EOF
    1
    <pipeline_namespace> は、パイプラインの namespace に置き換えます。
  3. 次のコマンドを実行して、pipeline サービスアカウントにロールを割り当てます。

    $ oc create rolebinding shared-resource-rhel-entitlement --role=shared-shared-resource-rhel-entitlement \
      --serviceaccount=<pipeline-namespace>:pipeline 1
    1
    <pipeline-namespace> をパイプラインの namespace に置き換えます。
    注記

    OpenShift Pipelines のデフォルトのサービスアカウントを変更した場合、またはパイプライン実行またはタスク実行でカスタムサービスアカウントを定義した場合は、pipeline アカウントではなくこのアカウントにロールを割り当てます。

  4. Buildah タスク定義では、openshift-pipelines namespace で提供されている buildah タスクまたはこのタスクのコピーを使用して、次の例に示すように rhel-entitlement ワークスペースを定義します。
  5. タスク実行または Buildah タスクを実行するパイプライン実行で、次の例のように、共有シークレットを rhel-entitlement ワークスペースに割り当てます。

Red Hat エンタイトルメントを使用するパイプライン実行定義の例 (パイプラインとタスクの定義を含む)

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: buildah-pr-test-csi
spec:
  workspaces:
    - name: shared-workspace
      volumeClaimTemplate:
        spec:
          accessModes:
          - ReadWriteOnce
          resources:
            requests:
              storage: 1Gi
    - name: dockerconfig
      secret:
        secretName: regred
    - name: rhel-entitlement  1
      csi:
        readOnly: true
        driver: csi.sharedresource.openshift.io
        volumeAttributes:
          sharedSecret: shared-rhel-entitlement
  pipelineSpec:
    workspaces:
    - name: shared-workspace
    - name: dockerconfig
    - name: rhel-entitlement  2
    tasks:
# ...
    - name: buildah
      taskRef:
        resolver: cluster
        params:
        - name: kind
          value: task
        - name: name
          value: buildah
        - name: namespace
          value: openshift-pipelines
      workspaces:
      - name: source
        workspace: shared-workspace
      - name: dockerconfig
        workspace: dockerconfig
      - name: rhel-entitlement  3
        workspace: rhel-entitlement
      params:
      - name: IMAGE
        value: <image_where_you_want_to_push>

1
パイプライン実行における rhel-entitlement ワークスペースの定義。shared-rhel-entitlement CSI 共有シークレットがワークスペースに割り当てられます。
2
パイプライン定義の rhel-entitlement ワークスペースの定義
3
タスク定義の rhel-entitlement ワークスペースの定義
Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

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

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

会社概要

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

© 2024 Red Hat, Inc.