|
| 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 {product-title} cluster on Azure with the service principal or managed identity as an Azure identity in one subscription (call it Subscription A) |
| 11 | +
|
| 12 | +* Access to another subscription (call it Subscription B) with the storage that is in the same tenant as 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 a later step: |
| 20 | ++ |
| 21 | +* If using the _service principal_ as the 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 the 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 | +. Grant the Azure identity (service principal or managed identity) permission to access the resource group in another Subscription B where you want to provision the Azure File share by doing one of the following: |
| 40 | + |
| 41 | +* Run the following Azure CLI command: |
| 42 | ++ |
| 43 | +[source,terminal] |
| 44 | +---- |
| 45 | +az role assignment create \ |
| 46 | + --assignee <object-id-or-app-id> \ |
| 47 | + --role <role-name> \ |
| 48 | + --scope /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Storage/storageAccounts/<storage-account-name> |
| 49 | +---- |
| 50 | ++ |
| 51 | +Where: |
| 52 | ++ |
| 53 | +`<object-id-or-app-id>`: The service principal or managed identity that you obtained from the previous step, such as `sp_id` or `mi_id`. |
| 54 | ++ |
| 55 | +`<role-name>`: Role name. Contributor or your own role with required permissions. |
| 56 | ++ |
| 57 | +`<subscription-id>`: Subscription B ID. |
| 58 | ++ |
| 59 | +`<resource-group-name>`: Subscription B resource group name. |
| 60 | ++ |
| 61 | +Or |
| 62 | ++ |
| 63 | +* Log in to the Azure portal and on the left menu, click *Resource groups*: |
| 64 | +
|
| 65 | +.. Choose the resource group in Subscription B 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*. |
| 66 | + |
| 67 | +.. 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. |
| 68 | + |
| 69 | +.. On the *Members* tab: |
| 70 | +... Choose an assignee by selecting the type of assignee: user, group, or service principal (or managed identity). |
| 71 | +... Click *Select members*. |
| 72 | +... Search for, and then select the desired service principal or managed identity recorded in the previous step. |
| 73 | +... Click *Select* to confirm. |
| 74 | +.. On the *Review + assign* tab, review the settings. |
| 75 | + |
| 76 | +.. To finish the role assignment, click *Review + assign*. |
| 77 | ++ |
| 78 | +[NOTE] |
| 79 | +==== |
| 80 | +If you only 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 by using similar steps. |
| 81 | +==== |
| 82 | + |
| 83 | +. Create an Azure File storage class by using a similar configuration to the following: |
| 84 | ++ |
| 85 | +.Example Azure File storage class YAML file |
| 86 | +[source, yaml] |
| 87 | +---- |
| 88 | +allowVolumeExpansion: true |
| 89 | +apiVersion: storage.k8s.io/v1 |
| 90 | +kind: StorageClass |
| 91 | +metadata: |
| 92 | + name: <sc-name> <1> |
| 93 | +mount options: |
| 94 | + - mfsymlinks |
| 95 | + - cache=strict |
| 96 | + - nosharesock |
| 97 | + - actimeo=30 |
| 98 | +parameters: |
| 99 | + subscriptionID: <xxxx-xxxx-xxxx-xxxx-xxxx> <2> |
| 100 | + resourceGroup: <resource group name> <3> |
| 101 | + storageAccount: <storage account> <4> |
| 102 | + skuName: <skuName> <5> |
| 103 | +provisioner: file.csi.azure.com |
| 104 | +reclaimPolicy: Delete |
| 105 | +volumeBindingMode: Immediate |
| 106 | +---- |
| 107 | +<1> The name of the storage class |
| 108 | +<2> The subscription B ID |
| 109 | +<3> The Subscription B resource group name |
| 110 | +<4> The storage account name, if you want to specify your own |
| 111 | +<5> The name of the SKU type |
| 112 | + |
| 113 | +. Create a persistent volume claim (PVC) that specifies the Azure File storage class that you created in the previous step by using a similar configuration to the following: |
| 114 | ++ |
| 115 | +.Example PVC YAML file |
| 116 | +[source, yaml] |
| 117 | +---- |
| 118 | +apiVersion: v1 |
| 119 | +kind: PersistentVolumeClaim |
| 120 | +metadata: |
| 121 | + name: <pvc-name> <1> |
| 122 | +spec: |
| 123 | + storageClassName: <sc-name-cross-sub> <2> |
| 124 | + accessModes: |
| 125 | + - ReadWriteMany |
| 126 | + resources: |
| 127 | + requests: |
| 128 | + storage: 5Gi |
| 129 | +---- |
| 130 | +<1> The name of the PVC. |
| 131 | +<2> The name of the storage class that you created in the previous step. |
0 commit comments