Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7f626d4

Browse files
author
Lisa Pettyjohn
committedApr 11, 2025·
OSDOCS-13459#Add cross-subscription support for Azure File
1 parent 666dad7 commit 7f626d4

4 files changed

+214
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * storage/container_storage_interface/persistent_storage-csi-azure-file.adoc
4+
//
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="persistent-storage-csi-azure-file-cross-sub-dynamic-pre-provisioning-pv-pvc-procedure_{context}"]
7+
= Pre-provisioning across subscriptions for Azure File by creating a PV and PVC:
8+
9+
.Prerequisites
10+
* Installed Azure cluster with the service principal or managed identity as Azure identity
11+
12+
* Access to another subscription in the tenant with the cluster
13+
14+
* Logged in to the Azure CLI
15+
16+
.Procedure
17+
. For the desired existing Azure File share, record the resource group, storage account, storage account key, and Azure File name. These values are used for the next steps.
18+
19+
. Create a secret for the persistent volume parameter `spec.csi.nodeStageSecretRef.name` by running the following command:
20+
+
21+
[source, terminal]
22+
----
23+
$ oc create secret generic azure-storage-account-{storageaccount-name}-secret --from-literal=azurestorageaccountname="<azure-storage-account-name>" --from-literal azurestorageaccountkey="<azure-storage-account-key>" --type=Opaque <1>
24+
----
25+
<1> Where `<azure-storage-account-name>` and `<azure-storage-account-key>` are the Azure storage account name and key respectively that you recorded in Step 1.
26+
27+
. Create a persistent volume (PV) using a similar configuration to the following example file:
28+
+
29+
.Example PV YAML file
30+
[source, terminal]
31+
----
32+
apiVersion: v1
33+
kind: PersistentVolume
34+
metadata:
35+
annotations:
36+
pv.kubernetes.io/provisioned-by: file.csi.azure.com
37+
name: <pv-name> <1>
38+
spec:
39+
capacity:
40+
storage: 10Gi <2>
41+
accessModes:
42+
- ReadWriteMany
43+
persistentVolumeReclaimPolicy: Retain
44+
storageClassName: azurefile-csi-manual
45+
mountOptions:
46+
- cache=strict
47+
- nosharesock
48+
- actimeo=30
49+
- nobrl
50+
csi:
51+
driver: file.csi.azure.com
52+
volumeHandle: "{resource-group-name}#{storage-account-name}#{file-share-name}" <3>
53+
volumeAttributes:
54+
shareName: <existing-file-share-name> <4>
55+
nodeStageSecretRef:
56+
name: <secret-name> <5>
57+
namespace: <secret-namespace> <6>
58+
----
59+
<1> <pv-name> is the PV name.
60+
<2> The size of the PV.
61+
<3> Ensure that `volumeHandle` is unique for every identical share in the cluster.
62+
<4> For `<existing-file-share-name>, use only the file share name and not the full path.
63+
<5> <secret-name> is the secret name created in the previous step.
64+
<6> <secret-namespace> is the namespace where the secret resides.
65+
66+
. Create a persistent value claim (PVC) specifying the existing Azure File share referenced in Step 1 using a similar configuration to the following:
67+
+
68+
.Example PVC YAML file
69+
[source, yaml]
70+
----
71+
apiVersion: v1
72+
kind: PersistentVolumeClaim
73+
metadata:
74+
name: <pvc-name> <1>
75+
spec:
76+
storageClassName: <sc-name-cross-sub> <2>
77+
accessModes:
78+
- ReadWriteMany
79+
resources:
80+
requests:
81+
storage: 5Gi
82+
----
83+
<1> `<pvc-name>` is the name of the PVC.
84+
<2> `<sc-name-cross-sub>` is the name of the storage class.
85+
86+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * storage/container_storage_interface/persistent_storage-csi-azure-file.adoc
4+
//
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="persistent-storage-csi-azure-file-cross-sub-dynamic-provisioning-procedure_{context}"]
7+
= Dynamic provisioning across subscriptions for Azure File
8+
9+
.Prerequisites
10+
* Installed Azure cluster with the service principal or managed identity as Azure identity
11+
12+
* Access to another subscription in the tenant with the cluster
13+
14+
* Logged in to the Azure CLI
15+
16+
.Procedure
17+
To use Azure File dynamic provisioning across subscriptions:
18+
19+
. Record the Azure identity (service principal or managed identity) by running the following applicable commands. The Azure identity is needed in the next step:
20+
+
21+
* If using the _service principal_ as Azure identity when installing the cluster:
22+
+
23+
[source,terminal]
24+
====
25+
$ sp_id=$(oc -n openshift-cluster-csi-drivers get secret azure-file-credentials -o jsonpath='{.data.azure_client_id}' | base64 --decode)
26+
27+
$ az ad sp show --id ${sp_id} --query displayName --output tsv
28+
====
29+
+
30+
* If using the _managed identity_ as Azure identity when installing the cluster:
31+
+
32+
[source,terminal]
33+
====
34+
$ mi_id=$(oc -n openshift-cluster-csi-drivers get secret azure-file-credentials -o jsonpath='{.data.azure_client_id}' | base64 --decode)
35+
36+
$ az identity list --query "[?clientId=='${mi_id}'].{Name:name}" --output tsv
37+
====
38+
39+
. Obtain the Azure identity (service principal or managed identity) permission to access the resource group in another subscription where you want to provision the Azure File share:
40+
41+
.. Log in to the Azure portal and on the left-hand menu, click *Resource groups*.
42+
43+
.. Choose the resource group to which you want to assign a role by clicking *resource group* > *Access control (IAM)* > *Role assignments* tab to view current assignments, and then click *Add* > *Add role assignment*.
44+
45+
.. On the *Role* tab, choose the contributor role to assign, and then click *Next*. You can also create and choose your own role with required permission.
46+
47+
.. On the *Members* tab, choose an assignee by selecting the type of assignee: “User, group, or service principal” (Or “Managed identity”), click *Select members*, search for and then select the desired service principal or managed identity, and then click *Select* to confirm.
48+
49+
.. On the *Review + assign* tab, review the settings.
50+
51+
.. To finish the role assignment, click *Review + assign*.
52+
+
53+
[NOTE]
54+
====
55+
If you just want to use a specific storage account to provision the Azure File share, you can also obtain the Azure identity (service principal or managed identity) permission to access the storage account only with the similar steps.
56+
====
57+
58+
. Create an Azure File storage class using a similar configuration to the following:
59+
+
60+
.Example Azure File storage class YAML file
61+
[source, yaml]
62+
----
63+
allowVolumeExpansion: true
64+
apiVersion: storage.k8s.io/v1
65+
kind: StorageClass
66+
metadata:
67+
name: <sc-name-cross-sub> <1>
68+
mount options:
69+
- mfsymlinks
70+
- cache=strict
71+
- nosharesock
72+
- actimeo=30
73+
parameters:
74+
subscriptionID: <xxxx-xxxx-xxxx-xxxx-xxxx> <2>
75+
resourceGroup: <resource group name> <3>
76+
storageAccount: <storage account> <4>
77+
skuName: <skuName> <5>
78+
provisioner: file.csi.azure.com
79+
reclaimPolicy: Delete
80+
volumeBindingMode: Immediate
81+
----
82+
<1> Name of the storage class
83+
<2> The cross account subscription ID
84+
<3> The resource group name in cross account subscription
85+
<4> Storage account name, if you want to specify your own
86+
<5> Name of the SKU type
87+
88+
. Create a persistent volume claim (PVC) specifying the Azure File storage class that you created in the previous step using a similar configuration to the following:
89+
+
90+
.Example PVC YAML file
91+
[source, yaml]
92+
----
93+
apiVersion: v1
94+
kind: PersistentVolumeClaim
95+
metadata:
96+
name: <pvc-name> <1>
97+
spec:
98+
storageClassName: <sc-name-cross-sub> <2>
99+
accessModes:
100+
- ReadWriteMany
101+
resources:
102+
requests:
103+
storage: 5Gi
104+
----
105+
<1> `<pvc-name>` is the name of the PVC.
106+
<2> `<sc-name-cross-sub>` is the name of the storage class that you created in the previous step.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * storage/container_storage_interface/persistent_storage-csi-azure-file.adoc
4+
//
5+
6+
:_mod-docs-content-type: CONCEPT
7+
[id="persistent-storage-csi-azure-file-cross-sub-overview_{context}"]
8+
= Azure File cross-subscription support
9+
10+
Cross-subscription support allows you to have an {product-title} cluster in one Azure subscription and mount your Azure file share in another Azure subscription using the Azure File Container Storage Interface (CSI) driver.
11+
12+
[IMPORTANT]
13+
====
14+
Both the {product-title} cluster and the Azure File share (pre-provisioning or to be provisioned) should be inside the same tenant.
15+
====

‎storage/container_storage_interface/persistent-storage-csi-azure-file.adoc

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ Azure File CSI Driver Operator does _not_ support:
2525

2626
For more information about supported features, see xref:../../storage/container_storage_interface/persistent-storage-csi.adoc#csi-drivers-supported_persistent-storage-csi[Supported CSI drivers and features].
2727

28+
include::modules/persistent-storage-csi-about.adoc[leveloffset=+1]
29+
2830
include::modules/persistent-storage-csi-azure-file-nfs.adoc[leveloffset=+1]
2931

30-
include::modules/persistent-storage-csi-about.adoc[leveloffset=+1]
32+
include::modules/persistent-storage-csi-azure-file-cross-sub-overview.adoc[leveloffset=+1]
33+
34+
include::modules/persistent-storage-csi-azure-file-cross-sub-dynamic-provisioning-procedure.adoc[leveloffset=+2]
35+
36+
include::modules/persistent-storage-csi-azure-file-cross-sub-dynamic-pre-provisioning-pv-pvc-procedure.adoc[leveloffset=+2]
3137

3238
[role="_additional-resources"]
3339
.Additional resources

0 commit comments

Comments
 (0)
Please sign in to comment.