5.3. 共有リソース CSI ドライバー Operator を使用してシークレットを共有することによる Red Hat エンタイトルメントの使用
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 を有効にしている。
手順
次のコマンドを実行して、
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
$ 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
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行して、共有シークレットへのアクセスを許可する RBAC ロールを作成します。
oc apply -f - <<EOF apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: shared-resource-rhel-entitlement namespace: <pipeline_namespace> rules: - apiGroups: - sharedresource.openshift.io resources: - sharedsecrets resourceNames: - shared-rhel-entitlement verbs: - use EOF
$ 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
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
<pipeline_namespace>
は、パイプラインの namespace に置き換えます。
次のコマンドを実行して、
pipeline
サービスアカウントにロールを割り当てます。oc create rolebinding shared-resource-rhel-entitlement --role=shared-shared-resource-rhel-entitlement \ --serviceaccount=<pipeline-namespace>:pipeline
$ oc create rolebinding shared-resource-rhel-entitlement --role=shared-shared-resource-rhel-entitlement \ --serviceaccount=<pipeline-namespace>:pipeline
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
<pipeline-namespace>
をパイプラインの namespace に置き換えます。
注記OpenShift Pipelines のデフォルトのサービスアカウントを変更した場合、またはパイプライン実行またはタスク実行でカスタムサービスアカウントを定義した場合は、
pipeline
アカウントではなくこのアカウントにロールを割り当てます。-
Buildah タスク定義では、
openshift-pipelines
namespace で提供されているbuildah
タスクまたはこのタスクのコピーを使用して、次の例に示すようにrhel-entitlement
ワークスペースを定義します。 -
タスク実行または 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 csi: readOnly: true driver: csi.sharedresource.openshift.io volumeAttributes: sharedSecret: shared-rhel-entitlement pipelineSpec: workspaces: - name: shared-workspace - name: dockerconfig - name: rhel-entitlement 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 workspace: rhel-entitlement params: - name: IMAGE value: <image_where_you_want_to_push>
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
csi:
readOnly: true
driver: csi.sharedresource.openshift.io
volumeAttributes:
sharedSecret: shared-rhel-entitlement
pipelineSpec:
workspaces:
- name: shared-workspace
- name: dockerconfig
- name: rhel-entitlement
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
workspace: rhel-entitlement
params:
- name: IMAGE
value: <image_where_you_want_to_push>