add kubespray to the XTesting as it provides newer version of kubenetes and can be...
[it/test.git] / XTesting / kubespray / docs / azure-csi.md
1 # Azure Disk CSI Driver
2
3 The Azure Disk CSI driver allows you to provision volumes for pods with a Kubernetes deployment over Azure Cloud. The CSI driver replaces to volume provisioning done by the in-tree azure cloud provider which is deprecated.
4
5 This documentation is an updated version of the in-tree Azure cloud provider documentation (azure.md).
6
7 To deploy Azure Disk CSI driver, uncomment the `azure_csi_enabled` option in `group_vars/all/azure.yml` and set it to `true`.
8
9 ## Azure Disk CSI Storage Class
10
11 If you want to deploy the Azure Disk storage class to provision volumes dynamically, you should set `persistent_volumes_enabled` in `group_vars/k8s_cluster/k8s_cluster.yml` to `true`.
12
13 ## Parameters
14
15 Before creating the instances you must first set the `azure_csi_` variables in the `group_vars/all.yml` file.
16
17 All of the values can be retrieved using the azure cli tool which can be downloaded here: <https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest>
18
19 After installation you have to run `az login` to get access to your account.
20
21 ### azure\_csi\_tenant\_id + azure\_csi\_subscription\_id
22
23 Run `az account show` to retrieve your subscription id and tenant id:
24 `azure_csi_tenant_id` -> tenantId field
25 `azure_csi_subscription_id` -> id field
26
27 ### azure\_csi\_location
28
29 The region your instances are located in, it can be something like `francecentral` or `norwayeast`. A full list of region names can be retrieved via `az account list-locations`
30
31 ### azure\_csi\_resource\_group
32
33 The name of the resource group your instances are in, a list of your resource groups can be retrieved via `az group list`
34
35 Or you can do `az vm list | grep resourceGroup` and get the resource group corresponding to the VMs of your cluster.
36
37 The resource group name is not case sensitive.
38
39 ### azure\_csi\_vnet\_name
40
41 The name of the virtual network your instances are in, can be retrieved via `az network vnet list`
42
43 ### azure\_csi\_vnet\_resource\_group
44
45 The name of the resource group your vnet is in, can be retrieved via `az network vnet list | grep resourceGroup` and get the resource group corresponding to the vnet of your cluster.
46
47 ### azure\_csi\_subnet\_name
48
49 The name of the subnet your instances are in, can be retrieved via `az network vnet subnet list --resource-group RESOURCE_GROUP --vnet-name VNET_NAME`
50
51 ### azure\_csi\_security\_group\_name
52
53 The name of the network security group your instances are in, can be retrieved via `az network nsg list`
54
55 ### azure\_csi\_aad\_client\_id + azure\_csi\_aad\_client\_secret
56
57 These will have to be generated first:
58
59 - Create an Azure AD Application with:
60 `az ad app create --display-name kubespray --identifier-uris http://kubespray --homepage http://kubespray.com --password CLIENT_SECRET`
61
62 Display name, identifier-uri, homepage and the password can be chosen
63
64 Note the AppId in the output.
65
66 - Create Service principal for the application with:
67 `az ad sp create --id AppId`
68
69 This is the AppId from the last command
70
71 - Create the role assignment with:
72 `az role assignment create --role "Owner" --assignee http://kubespray --subscription SUBSCRIPTION_ID`
73
74 azure\_csi\_aad\_client\_id must be set to the AppId, azure\_csi\_aad\_client\_secret is your chosen secret.
75
76 ### azure\_csi\_use\_instance\_metadata
77
78 Use instance metadata service where possible. Boolean value.
79
80 ## Test the Azure Disk CSI driver
81
82 To test the dynamic provisioning using Azure CSI driver, make sure to have the storage class deployed (through persistent volumes), and apply the following manifest:
83
84 ```yml
85 ---
86 apiVersion: v1
87 kind: PersistentVolumeClaim
88 metadata:
89   name: pvc-azuredisk
90 spec:
91   accessModes:
92     - ReadWriteOnce
93   resources:
94     requests:
95       storage: 1Gi
96   storageClassName: disk.csi.azure.com
97 ---
98 kind: Pod
99 apiVersion: v1
100 metadata:
101   name: nginx-azuredisk
102 spec:
103   nodeSelector:
104     kubernetes.io/os: linux
105   containers:
106     - image: nginx
107       name: nginx-azuredisk
108       command:
109         - "/bin/sh"
110         - "-c"
111         - while true; do echo $(date) >> /mnt/azuredisk/outfile; sleep 1; done
112       volumeMounts:
113         - name: azuredisk
114           mountPath: "/mnt/azuredisk"
115   volumes:
116     - name: azuredisk
117       persistentVolumeClaim:
118         claimName: pvc-azuredisk
119 ```