1.2. namespace 間でのシークレットの共有
クラスター内の namespace 間でシークレットを共有するには、Secret
オブジェクトの SharedSecret
カスタムリソース (CR) インスタンスを作成します。
前提条件
-
他の namespace で共有する
Secret
オブジェクトを作成している。 次の操作を実行するための権限がある。
- クラスターにサブスクライブし、Insights Operator を通じてエンタイトルメントキーを同期する。
-
クラスタースコープレベルで
sharedsecrets.sharedresource.openshift.io
カスタムリソース定義 (CRD) のインスタンスを作成する。 -
SharedConfigMap CR
のClusterRole
オブジェクトを作成する。 -
Shared Resource CSI Driver の
Role
オブジェクトとRoleBinding
オブジェクトを作成する。 - ユーザーを制御するために、クラスター内の namespace 全体でロールとロールバインディングを管理する。
-
ロールとロールバインディングを管理して、Pod によって指定されたサービスアカウントが、
Secret
またはConfigmap
CR を参照する Container Storage Interface (CSI) ボリュームをマウントできるかどうかを制御する。 - 共有するシークレットが含まれている namespace にアクセスする。
手順
次の例の設定を使用して、クラスター内の namespace 全体で参照される
Secret
を共有するSharedSecret
インスタンスを作成します。apiVersion: sharedresource.openshift.io/v1alpha1 kind: SharedSecret metadata: name: shared-test-secret spec: secretRef: name: test-secret namespace: <name_of_the_source_namespace>
apiVersion: sharedresource.openshift.io/v1alpha1 kind: SharedSecret metadata: name: shared-test-secret
1 spec: secretRef: name: test-secret namespace: <name_of_the_source_namespace>
Copy to Clipboard Copied! - 1
SharedSecret
CR の名前を定義します。
次の設定例を使用して、参照される共有リソースを使用するための RBAC 権限を付与する
ClusterRole
オブジェクトを作成します。. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: use-shared-test-secret rules: - apiGroups: - sharedresource.openshift.io resources: - sharedsecrets resourceNames: - shared-test-secret verbs: - use
. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: use-shared-test-secret
1 rules: - apiGroups: - sharedresource.openshift.io resources: - sharedsecrets resourceNames: - shared-test-secret verbs: - use
Copy to Clipboard Copied! - 1
ClusterRole
CR の名前を定義します。
Shared Resources CSI Driver に
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
2 subjects: - kind: ServiceAccount name: csi-driver-shared-resource
3 namespace: openshift-builds
Copy to Clipboard Copied!