Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 1. Shared Resource CSI Driver
To securely share Secret and ConfigMap objects across namespaces, use the Shared Resource Container Storage Interface (CSI) driver with the csi volume type. This driver provisions inline ephemeral volumes, enabling pods and Builds to utilize these shared configuration resources.
1.1. Sharing a Secret object across namespaces Copier lienLien copié sur presse-papiers!
A SharedSecret custom resource (CR) enables secure sharing of Secret objects containing sensitive information like passwords, OAuth tokens, and SSH keys across namespaces within a cluster. This eliminates manual duplication and provides a single source for sensitive data with controlled access.
1.1.1. Creating a SharedSecret custom resource Copier lienLien copié sur presse-papiers!
Create a SharedSecret custom resource (CR) to share a Secret object across namespaces. By creating a SharedSecret custom resource (CR), you can share a Secret object across namespaces, ensuring that sensitive configuration data remains consistently accessible cluster-wide.
Prerequisites
- You are logged in to the OpenShift Container Platform cluster as an administrator.
-
You have created a
Secretobject that you want to share in other namespaces. To create aSecretobject, see "Creating Secrets". - You have subscribed to the cluster and have entitlement keys synced through the Insights Operator.
You must have permissions to perform the following actions:
-
Create the
sharedsecrets.sharedresource.openshift.ioCR at a cluster-scoped level. -
Create the
ClusterRoleobject for theSharedSecretCR. -
Create the
RoleandRoleBindingobjects for the Shared Resource CSI Driver. - Manage roles and role bindings across the namespaces in the cluster to control users.
-
Manage roles and role bindings so that the service account specified by a pod can use the
SharedSecretCR to mount a CSI volume that references aSecretobject. -
Access to the namespaces that contain the
Secretobject you want to share.
-
Create the
Procedure
Create the
RoleandRoleBindingobjects that grant the Shared Resource CSI driver the permission to access theSharedSecretobject by using the following example configurations:Example
RoleobjectapiVersion: 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-
metadata.namedefines the name of theRoleCR.
Example
RoleBindingobjectapiVersion: 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-
metadata.namedefines the name of theRoleBindingCR. -
roleRef.namedefines the name of theRoleCR. -
subjects.namedefines the name of theServiceAccountCR.
-
Create a
SharedSecretCR by using the following example configuration:apiVersion: sharedresource.openshift.io/v1alpha1 kind: SharedSecret metadata: name: shared-test-secret spec: secretRef: name: test-secret namespace: openshift-config-managed-
spec.secretRef.namespacedefines the name of theSharedSecretCR.
-
Create a
ClusterRoleobject that grants RBAC permission to use the referenced shared resource by using the following example configuration: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-
metadata.namedefines the name of theClusterRoleCR.
-
Verification
Run the following command to verify that the required
Roleis created:$ oc get role share-etc-pki-entitlement -n openshift-config-managedExample output
NAME CREATED AT share-etc-pki-entitlement 2025-11-19T12:05:32ZRun the following command to verify that the required
RoleBindingis created:$ oc get rolebinding share-etc-pki-entitlement -n openshift-config-managedExample output
NAME ROLE AGE share-etc-pki-entitlement Role/share-etc-pki-entitlement 2mRun the following command to verify that the required
ClusterRoleis created:$ oc get clusterrole use-shared-test-secretExample output
NAME CREATED AT use-shared-test-secret 2025-11-19T12:05:44Z
1.1.2. Using a SharedSecret custom resource in a pod Copier lienLien copié sur presse-papiers!
To access the SharedSecret custom resource (CR) from a pod, you grant role-based access control (RBAC) permission to a service account.
Prerequisites
You are logged in to the OpenShift Container Platform cluster as one of the following users:
-
A cluster administrator who has created the
SharedSecretCR instance for theSecretobject. -
A user with permissions to access the target namespaces and to create or manage the
SharedSecretcustom resource for theSecretto be shared.
-
A cluster administrator who has created the
You must have permissions to perform the following actions:
-
Run the
oc adm policy who-can use <sharedsecret_identifier>command to check if a service account is allowed to use theSharedSecretCR and the service account is listed in your namespace. -
Confirm that the service account of your pod is allowed to use the
csivolume. If you created the pod as a user, confirm that you are allowed to use thecsivolume.
-
Run the
If you are unable to complete the last two prerequisites, the cluster administrator can establish the necessary RBAC permission so that you can enable service accounts to use the SharedSecret CR.
Procedure
Create the
RoleBindingobject in the cluster associated with the role and grant the permission to your service account to use the shared resource. See the following example configuration:apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: use-shared-secret namespace: app-namespace roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: use-shared-secret subjects: - kind: ServiceAccount name: <service_account_name>where:
metadata.name-
Defines the name of the
RoleBindingCR. <service_account_name>- Specifies the name of the service account of your application.
Mount the shared resource
csidriver into a pod or any other resource that acceptscsivolumes. See the following example configuration:apiVersion: v1 kind: Pod metadata: name: example-shared-secret namespace: <app_namespace> spec: ... serviceAccountName: default volumes: - name: shared-secret csi: readOnly: true driver: csi.sharedresource.openshift.io volumeAttributes: sharedSecret: shared-test-secretwhere:
<app_namespace>- Specifies the name of the namespace of your application.
volumes.volumeAttributes.sharedSecret-
Defines the value of the
sharedSecretattribute that must be same as the name of theSharedSecretCR.
ImportantThe pod fails to start in the following cases:
-
The value of the
sharedSecretattribute does not match the name of theSharedSecretinstance. -
A volume is defined but not mounted, the pod stays in the
ContainerCreatingstate and eventually fails.
Verification
Run the following command to verify the permission granted to your service account:
$ oc describe rolebinding share-etc-pki-entitlement -n openshift-config-managedExample output:
Name: share-etc-pki-entitlement Labels: <none> Annotations: <none> Role: Kind: Role Name: share-etc-pki-entitlement Subjects: Kind Name Namespace ---- ---- --------- ServiceAccount csi-driver-shared-resource openshift-builds
1.2. Sharing a ConfigMap object across namespaces Copier lienLien copié sur presse-papiers!
A ConfigMap object stores non-sensitive data, such as URLs or feature flags. By using a SharedConfigMap custom resource (CR), you can share a ConfigMap object across namespaces without duplication, providing a single configuration source and ensuring consistency cluster-wide.
1.2.1. Creating a SharedConfigMap custom resource Copier lienLien copié sur presse-papiers!
Create a SharedConfigMap custom resource (CR) to share a ConfigMap object across namespaces. By creating a SharedConfigMap custom resource (CR), you can share configuration data across namespaces, ensuring that sensitive configuration data remains consistently accessible cluster-wide.
Prerequisites
- You are logged in to the OpenShift Container Platform cluster as an administrator.
-
You have created a
ConfigMapobject that you want to share in other namespaces. To create aConfigMapobject, see "Adding input secrets and configmaps". You must have permissions to perform the following actions:
-
Create the
sharedconfigmaps.sharedresource.openshift.ioCR at a cluster-scoped level. -
Create a
ClusterRoleobject for theSharedConfigMapCR. -
Create the
RoleandRoleBindingobjects for the Shared Resource Container Storage Interface (CSI) Driver. - Manage roles and role bindings across the namespaces in the cluster to control which users can get, list, and watch instances.
-
Manage roles and role bindings so that the service account specified by a pod can use the
SharedConfigMapCR to mount acsivolume that references aConfigMapobject. -
Access the namespaces that contain the
ConfigMapobject you want to share.
-
Create the
Procedure
Create a
RoleandRoleBindingobject to grant the Shared Resource CSI Driver permission to access theConfigMapobject. See the following example configuration:Example
RoleobjectapiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: shared-test-config namespace: <name_of_the_source_namespace> rules: - apiGroups: [""] resources: ["configmaps"] resourceNames: ["shared-config"] verbs: ["get", "list", "watch"]where:
<name_of_the_source_namespace>- Specifies the name of the source namespace.
Example
RoleBindingobjectapiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: shared-test-config namespace: <name_of_the_source_namespace> roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: shared-test-config subjects: - kind: ServiceAccount name: csi-driver-shared-resource namespace: openshift-buildswhere:
<name_of_the_source_namespace>- Specifies the name of the source namespace.
subjects-
Specifies a list of service accounts for the Shared Resource CSI driver DaemonSet. When deployed with builds for Red Hat OpenShift, the service account name is
csi-driver-shared-resource, and the namespace matches the one where the Builds for Red Hat OpenShift Operator is deployed.
Create a
SharedConfigMapCR for theConfigMapobject that you want to share across namespaces in the cluster. The following example shows a sample configuration:apiVersion: sharedresource.openshift.io/v1alpha1 kind: SharedConfigMap metadata: name: share-test-config spec: configMapRef: name: shared-config namespace: <name_of_the_source_namespace>where:
metadata.name-
Specifies the name of the
SharedConfigMapCR. <name_of_the_source_namespace>- Specifies the name of your source namespace.
Create a
ClusterRoleCR instance that grants role-based access control (RBAC) permission to use the referenced shared resource. The following example shows a sample configuration:apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: <cluster_role_name> rules: - apiGroups: - sharedresource.openshift.io resources: - sharedconfigmaps resourceNames: - share-test-config verbs: - usewhere:
<cluster_role_name>- Specifies the name of your cluster role.
rules.resourceNames-
Defines name of the
SharedConfigMapCR.
Verification
Run the following command to verify that the required
Roleis created:$ oc get role share-etc-pki-entitlement -n openshift-config-managedExample output
NAME CREATED AT share-etc-pki-entitlement 2025-11-19T12:05:32ZRun the following command to verify that the required
RoleBindingis created:$ oc get rolebinding share-etc-pki-entitlement -n openshift-config-managedExample output
NAME ROLE AGE share-etc-pki-entitlement Role/share-etc-pki-entitlement 2mRun the following command to verify that the required
ClusterRoleis created:$ oc get clusterrole use-shared-test-secretExample output
NAME CREATED AT use-shared-test-secret 2025-11-19T12:05:44Z
1.2.2. Using a SharedConfigMap custom resource in a pod Copier lienLien copié sur presse-papiers!
To access a SharedConfigMap custom resource (CR) from a pod, you must grant the associated service account the necessary role-based access control (RBAC) permissions to use that SharedConfigMap CR.
Prerequisites
You are logged in to the OpenShift Container Platform cluster as one of the following users:
-
A cluster administrator who has created the
SharedConfigMapCR instance for theConfigMapobject. -
A user with permissions to access the target namespaces and to create or manage the
SharedConfigMapCR for theConfigMapto be shared.
-
A cluster administrator who has created the
You must have permissions to perform the following actions:
-
Run the
oc get sharedconfigmapscommand to get the list of theSharedConfigMapCR instances. -
Run the
oc adm policy who-can use <sharedsecret_identifier>command to check if a service account is allowed to use theSharedSecretCR and the service account is listed in your namespace. -
Run the
oc describe clusterrole <roleName>command to confirm that the service account of your pod is allowed to usecsivolumes. If you created the pod as a user, confirm that you are allowed to usecsivolumes.
-
Run the
If you are unable to complete the last two prerequisites, the cluster administrator can grant you the RBAC permission to enable the service accounts to use the SharedConfigMap CR.
Procedure
Create the
RoleBindingobject associated with the role and grant the permission to your service account to use the shared resource.apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: use-shared-config namespace: <app_namespace> roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: use-shared-config subjects: - kind: ServiceAccount name: <service_account_name>where:
<app_namespace>- Specifies the name of the namespace of your application.
<service_account_name>- Specifies the service account name of your application.
Mount the Shared Resource Container Storage Interface (CSI) Driver into a pod or any other resource that accepts
csivolumes.apiVersion: v1 kind: Pod metadata: name: example-shared-config namespace: <app_namespace> spec: ... serviceAccountName: default volumes: - name: shared-config csi: readOnly: true driver: csi.sharedresource.openshift.io volumeAttributes: sharedConfigMap: share-test-configwhere:
<app_namespace>- Specifies the name of the namespace of your application.
volumes.volumeAttributes.sharedConfigMap-
Specifies the name of the
sharedConfigMapobject.
ImportantThe pod fails to start in the following cases:
-
The value of the
SharedConfigMapattribute does not match the name of theSharedConfigMapinstance. -
A volume is defined but not mounted, the pod stays in the
ContainerCreatingstate and eventually fails.
Verification
Run the following command to verify the permission granted to your service account:
$ oc describe rolebinding share-etc-pki-entitlement -n openshift-config-managedExample output:
Name: share-etc-pki-entitlement Labels: <none> Annotations: <none> Role: Kind: Role Name: share-etc-pki-entitlement Subjects: Kind Name Namespace ---- ---- --------- ServiceAccount csi-driver-shared-resource openshift-builds
1.3. Building images using RHEL entitlements Copier lienLien copié sur presse-papiers!
If you have a Red Hat Enterprise Linux (RHEL) entitlement, the Insights Operator automatically manages the entitlement keys using the Simple Content Access (SCA) feature. With SCA, the RHEL systems access the subscription content without manually managing the entitlement keys. The Insights Operator imports your SCA entitlement keys and stores them in a secret called etc-pki-entitlement in the openshift-config-managed namespace.
Previously, a cluster administrator would manually copy the etc-pki-entitlement secret to the required namespace. Starting with OpenShift Container Platform 4.10 and later, builds for Red Hat OpenShift can share the etc-pki-entitlement secret from the openshift-config-managed namespace with other namespaces by using the Shared Resource Container Storage Interface (CSI) Driver Operator.
1.3.1. Sharing RHEL entitlement across namespaces Copier lienLien copié sur presse-papiers!
You can use a SharedSecret object to securely share and synchronize the RHEL entitlement keys of a cluster in Builds across namespaces.
Prerequisites
You must have permissions to perform the following actions:
-
Create
SharedSecretobject. - Create build configs and start builds.
-
Run the
oc get sharedsecretscommand to discover whichSharedSecretcustom resource (CR) instances are available. -
Run the
oc adm policy who-can use <sharedsecret_identifier>command to check if a service account is allowed to use theSharedSecretCR and the service account is listed in your namespace.
-
Create
If you are unable to complete the last two prerequisites, the cluster administrator can establish the necessary RBAC permission so that you can grant service accounts to use the SharedSecret CR.
Procedure
Create a
SharedSecretobject instance with the entitlement secret of a cluster by running the following command:$ 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 EOFwhere:
metadata.name-
Specifies the name of the
SharedSecretobject.
Create a
ClusterRoleobject to grant permission to access theSharedSecretobject by using the following example configuration: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: - usewhere:
metadata.name-
Specifies the name of the
ClusterRoleCR.
Create the
RoleandRoleBindingobject that grants the Shared Resource CSI driver the permission to access theSharedSecretobject:Example
Roleobject:
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
+
where:
metadata.name-
Specifies the name of the
RoleCR.
+ Example RoleBinding object:
+
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
+ where:
metadata.name-
Specifies the name of the
RoleBindingCR. subjects.namespaceSpecifies the name of the namespace where
openshift-buildsis installed.Create a
RoleBindingobject for thebuilderandpipelineservice accounts in the namespace where builds run: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: builderwhere:
metadata.nameSpecifies the name of the
RoleBindingCR for thebuilderandpipelineservice accounts.NoteThe service account that consumes the
SharedSecretobject is created and managed by the OpenShift controllers.Mount the
SharedSecretobject by using thebuildahbuild strategy. See the following example:$ 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> EOFwhere:
volumes.csi.readOnly-
Specifies the
readOnlyvalue to mount the shared resource in the build. volumes.csi.volumeAttributes.sharedSecret-
Specifies the name of the
SharedSecretobject to include it in the build. volumes.output.image- Specifies the location where you want to push the built image.