Work with Shared Resources
Using Shared Resources CSI Driver Operator
Abstract
Chapter 1. Shared Resource CSI Driver Operator Copy linkLink copied to clipboard!
Storage vendors have traditionally provided storage drivers as a part of Kubernetes. With the implementation of the Container Storage Interface (CSI), third-party providers can deliver storage plugins by using a standard interface without changing the core Kubernetes code. CSI Operators give Builds' users storage options, such as volume snapshots that are not possible with in-tree volume plugins.
The Shared Resource CSI driver is a special type of CSI driver that allows cluster administrators to securely share Secret and ConfigMap objects across namespaces by using the csi volume type. The Shared resources CSI driver provisions inline ephemeral volumes, enabling pods and OpenShift Container Platform Builds to use these shared resources.
The Shared Resource CSI driver supports the following types of custom resources:
-
SharedSecretcustom resource for sharingSecretobjects -
SharedConfigMapcustom resource for sharingConfigMapobjects
1.1. Sharing a Secret object across namespaces Copy linkLink copied to clipboard!
A Secret object is used to store and manage sensitive information, such as passwords, OAuth tokens, and SSH keys. You can use a SharedSecret custom resource (CR) to securely share a Secret object across different namespaces within a cluster without duplicating it manually. Sharing the Secret object provides a single source for sensitive data and ensures that authorized namespaces have access to it.
1.1.1. Creating a SharedSecret custom resource Copy linkLink copied to clipboard!
You can create a SharedSecret custom resource (CR) to share a Secret object across namespaces.
Prerequisites
-
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 - 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
- Name of the
RoleCR.
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-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-entitlement2 subjects: - kind: ServiceAccount name: csi-driver-shared-resource3 namespace: openshift-buildsCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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: <name_of_the_source_namespace>apiVersion: sharedresource.openshift.io/v1alpha1 kind: SharedSecret metadata: name: shared-test-secret1 spec: secretRef: name: test-secret namespace: <name_of_the_source_namespace>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<name_of_the_source_namespace>with 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: - useapiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: use-shared-test-secret1 rules: - apiGroups: - sharedresource.openshift.io resources: - sharedsecrets resourceNames: - shared-test-secret verbs: - useCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Name of the
ClusterRoleCR.
1.1.2. Using a SharedSecret custom resource in a pod Copy linkLink copied to clipboard!
To access the SharedSecret custom resource (CR) from a pod, you grant role-based access control (RBAC) permission to a service account.
Prerequisites
-
You have created a
SharedSecretCR instance for theSecretobject that you want to share across namespaces in the cluster. 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>apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: use-shared-secret1 namespace: app-namespace roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: use-shared-secret subjects: - kind: ServiceAccount name: <service_account_name>2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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-secretapiVersion: v1 kind: Pod metadata: name: example-shared-secret namespace: <app_namespace>1 spec: ... serviceAccountName: default volumes: - name: shared-secret csi: readOnly: true driver: csi.sharedresource.openshift.io volumeAttributes: sharedSecret: shared-test-secret2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIf the value of the
sharedSecretattribute does not match the name of theSharedSecretinstance, the pod fails to start.
1.2. Sharing a ConfigMap object across namespaces Copy linkLink copied to clipboard!
A ConfigMap object stores non-sensitive configuration data, such as application URLs or feature flags. A SharedConfigMap custom resource (CR) enables you to securely share a ConfigMap object across multiple namespaces in a cluster without manual duplication. By sharing a ConfigMap object, you establish a single source of configuration data and ensure consistency across the cluster.
1.2.1. Creating a SharedConfigMap custom resource Copy linkLink copied to clipboard!
You can create a SharedConfigMap custom resource (CR) instance to share a ConfigMap object across namespaces.
Prerequisites
-
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"]apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: shared-test-config namespace: <name_of_the_source_namespace>1 rules: - apiGroups: [""] resources: ["configmaps"] resourceNames: ["shared-config"] verbs: ["get", "list", "watch"]Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<name_of_the_source_namespace>with 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-buildsapiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: shared-test-config namespace: <name_of_the_source_namespace>1 roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: shared-test-config subjects:2 - kind: ServiceAccount name: csi-driver-shared-resource namespace: openshift-buildsCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<name_of_the_source_namespace>with the name of the source namespace. - 2
- 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>apiVersion: sharedresource.openshift.io/v1alpha1 kind: SharedConfigMap metadata: name: share-test-config1 spec: configMapRef: name: shared-config namespace: <name_of_the_source_namespace>2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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: - useapiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: <cluster_role_name>1 rules: - apiGroups: - sharedresource.openshift.io resources: - sharedconfigmaps resourceNames: - share-test-config2 verbs: - useCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2.2. Using a SharedConfigMap custom resource in a pod Copy linkLink copied to clipboard!
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 have created a
SharedConfigMapCR instance for the config map that you want to share across namespaces in the cluster. 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>apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: use-shared-config namespace: <app_namespace>1 roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: use-shared-config subjects: - kind: ServiceAccount name: <service_account_name>2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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-configapiVersion: v1 kind: Pod metadata: name: example-shared-config namespace: <app_namespace>1 spec: ... serviceAccountName: default volumes: - name: shared-config csi: readOnly: true driver: csi.sharedresource.openshift.io volumeAttributes: sharedConfigMap: share-test-config2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIf the value of
sharedConfigMapattribute does not match the name ofsharedConfigMapinstance, the pod fails to start.
1.3. Building images using RHEL entitlements Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
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 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 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: - 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
- Name of the
ClusterRoleCR.
Create the
RoleandRoleBindingobject that grants the Shared Resource CSI driver the permission to access theSharedSecretobject: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 - 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
- Name of the
RoleCR.
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-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 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: 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
- 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> 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
Legal Notice
Copy linkLink copied to clipboard!
Copyright © 2025 Red Hat
OpenShift documentation is licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
Modified versions must remove all Red Hat trademarks.
Portions adapted from https://github.com/kubernetes-incubator/service-catalog/ with modifications by Red Hat.
Red Hat, Red Hat Enterprise Linux, the Red Hat logo, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.