1.8. SharedSecret 오브젝트를 사용하여 빌드 실행
SharedSecret
오브젝트를 사용하여 빌드에서 클러스터의 RHEL 인타이틀먼트 키에 안전하게 액세스할 수 있습니다. SharedSecret
오브젝트를 사용하면 네임스페이스에서 보안을 공유하고 동기화할 수 있습니다.
사전 요구 사항
다음 작업을 수행할 수 있는 권한이 있어야 합니다.
- 빌드 구성을 생성하고 빌드를 시작합니다.
-
SharedSecret
오브젝트를 생성합니다. -
oc get sharedsecrets
명령을 입력하고 비어 있지 않은 목록을 다시 가져와서 사용할 수 있는SharedSecret
CR(사용자 정의 리소스) 인스턴스를 검색합니다. -
서비스 계정이
SharedSecret
CR을 사용하도록 허용된 경우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 EOF
Copy to Clipboard Copied! 다음 예제 구성을 사용하여
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: - use
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
Copy to Clipboard Copied! - 1
ClusterRole
CR의 이름을 정의합니다.
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 - watch
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
Copy to Clipboard Copied! - 1
Role
CR의 이름을 정의합니다.
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-builds
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 Copy to Clipboard Copied! 빌드가 실행되는 네임스페이스에서
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: builder
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
Copy to Clipboard Copied! - 1
builder
및pipeline
서비스 계정에 대한RoleBinding
CR의 이름을 정의합니다.
참고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: true
1 volumeAttributes: sharedSecret: <sharedsecret_object_name>
2 name: etc-pki-entitlement output: image: <output_image_location>
3 EOF
Copy to Clipboard Copied!