Installing the Azure Disk CSI driver

The Azure Disk CSI driver provides a Kubernetes CSI that allows AKS clusters to simply manage the life cycle of Azure Disk volumes for persistent volumes. In this recipe, we will learn the steps required to install the Azure Disk CSI driver by observing the following steps:

  1. Deploy the Azure Disk CSI driver:
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/deploy/crd-csi-driver-registry.yaml
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/deploy/crd-csi-node-info.yaml
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/deploy/rbac-csi-azuredisk-controller.yaml
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/deploy/csi-azuredisk-controller.yaml
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/deploy/csi-azuredisk-node.yaml
  1. Verify that the driver is running that controller and that the azuredisk-node DaemonSet is running:
$ kubectl get po -o wide -n kube-system | grep csi-azuredisk
csi-azuredisk-controller-9bc7f4d77-cbgxs 6/6 Running 0 5m31s 10.244.2.4 aks-agentpool-40109510-2 <none> <none>
csi-azuredisk-node-7kqzm 3/3 Running 0 5m27s 10.240.0.5 aks-agentpool-40109510-1 <none> <none>
csi-azuredisk-node-gm6dr 3/3 Running 0 5m27s 10.240.0.4 aks-agentpool-40109510-2 <none> <none>
csi-azuredisk-node-wqsls 3/3 Running 0 5m27s 10.240.0.6 aks-agentpool-40109510-0 <none> <none>
  1. Now, create a new storage class:
$ cat <<EOF | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: disk.csi.azure.com
provisioner: disk.csi.azure.com
parameters:
skuname: Standard_LRS
kind: managed
cachingMode: ReadOnly
reclaimPolicy: Delete
volumeBindingMode: Immediate
EOF
  1. Create a PVC using the storage class name, disk.csi.azure.com:
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: csi-azure-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: disk.csi.azure.com
resources:
requests:
storage: 4Gi
EOF
  1. Create a pod that will use the csi-azure-pvc PVC and that writes to the /data/out.txt file:
$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: mytestapp
spec:
containers:
- name: app
image: centos
command: ["/bin/sh"]
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"]
volumeMounts:
- name: persistent-storage
mountPath: /data
volumes:
- name: persistent-storage
persistentVolumeClaim:
claimName: csi-azure-pvc
EOF
  1. Verify that our mytestapp pod writes data to the volume:
$ kubectl exec -it mytestapp cat /data/out.txt
Mon Sep 9 19:23:29 UTC 2019

Now you know how to use the Azure Disk CSI driver to provision persistent volumes on your AKS clusters.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.184.102