Documentation for this version is no longer maintained.
View documentation for the latest supported version.1.8. SharedSecret 오브젝트를 사용하여 빌드 실행
SharedSecret 오브젝트를 사용하여 빌드에서 클러스터의 RHEL 인타이틀먼트 키에 안전하게 액세스할 수 있습니다. SharedSecret 오브젝트를 사용하면 네임스페이스에서 보안을 공유하고 동기화할 수 있습니다.
사전 요구 사항
다음 작업을 수행할 수 있는 권한이 있어야 합니다.
- 빌드 구성을 생성하고 빌드를 시작합니다.
-
SharedSecret오브젝트를 생성합니다. -
oc get sharedsecrets명령을 입력하고 비어 있지 않은 목록을 다시 가져와서 사용할 수 있는SharedSecretCR(사용자 정의 리소스) 인스턴스를 검색합니다. -
서비스 계정이
SharedSecretCR을 사용하도록 허용된 경우oc adm policy who-can use <sharedsecret_identifier> 명령을 실행하여 네임스페이스에 서비스 계정이 나열되어 있는지 확인합니다.
마지막 두 사전 요구 사항을 완료할 수 없는 경우 클러스터 관리자가 필요한 역할 기반 액세스 제어(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$ 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 EOFCopy to Clipboard Copied! Toggle word wrap Toggle overflow 다음 예제 구성을 사용하여
SharedSecret오브젝트에 액세스할 수 있는 권한을 부여할ClusterRole오브젝트를 생성합니다.apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: use-share-etc-pki-entitlement rules: - apiGroups: - sharedresource.openshift.io resources: - sharedsecrets resourceNames: - etc-pki-entitlement verbs: - useapiVersion: 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: - useCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
ClusterRoleCR의 이름을 정의합니다.
Shared Resources CSI 드라이버에
SharedSecret오브젝트에 액세스할 수 있는 권한을 부여하는Role및RoleBinding오브젝트를 생성합니다.Role오브젝트의 예apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: share-etc-pki-entitlement namespace: openshift-config-managed rules: - apiGroups: - "" resources: - secrets resourceNames: - etc-pki-entitlement verbs: - get - list - watchapiVersion: 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 - watchCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
RoleCR의 이름을 정의합니다.
RoleBinding오브젝트의 예apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: share-etc-pki-entitlement 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-buildsapiVersion: 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 Copy to Clipboard Copied! Toggle word wrap Toggle overflow 빌드가 실행되는 네임스페이스에서
builder및pipeline서비스 계정에 대한RoleBinding오브젝트를 생성합니다.apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: use-share-etc-pki-entitlement roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: use-share-etc-pki-entitlement subjects: - kind: ServiceAccount name: pipeline - kind: ServiceAccount name: builderapiVersion: 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: builderCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 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: true volumeAttributes: sharedSecret: <sharedsecret_object_name> name: etc-pki-entitlement output: image: <output_image_location> EOF$ 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 EOFCopy to Clipboard Copied! Toggle word wrap Toggle overflow