5.3. Shared Resources CSI 드라이버 Operator를 사용하여 시크릿을 공유하여 Red Hat 인타이틀먼트 사용
CSI(Share Resources Container Storage Interface) Driver Operator를 사용하여 openshift-config-managed
네임스페이스에서 다른 네임스페이스로 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! 다음 명령을 실행하여 공유 보안에 대한 액세스를 허용하는 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! - 1
- &
lt;pipeline_namespace&
gt;를 파이프라인의 네임스페이스로 바꿉니다.
다음 명령을 실행하여
파이프라인
서비스 계정에 역할을 할당합니다.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! - 1
- &
lt;pipeline-namespace&
gt;를 파이프라인의 네임스페이스로 바꿉니다.
참고OpenShift Pipelines의 기본 서비스 계정을 변경했거나 파이프라인 실행 또는 작업 실행에 사용자 정의 서비스 계정을 정의하는 경우 파이프라인 계정 대신 이 계정에 역할을 할당합니다.
-
Buildah 작업 정의에서
openshift-pipelines
네임스페이스에 제공된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>