# Use an Azure Disk volume

GKE on Azure automatically deploys the
[`azuredisk-csi-driver`](https://github.com/kubernetes-sigs/azuredisk-csi-driver)
to provision and manage Azure Disk volumes in your clusters.

The GKE on Azure Azure Disk CSI Driver version is tied to a Kubernetes cluster
version. The driver version is typically the latest available when the
GKE version is released. When the cluster is upgraded, the
drivers update automatically.

For more information on how GKE on Azure provides persistent storage,
see [Storage overview](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/azure/concepts/storage.md.txt).

## Default storage classes

GKE on Azure provides the following StorageClass options by default:

- [`standard-rwo`](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/azure/how-to/use-azure-disk.md.txt#standard) (default): Provisions standard SSD Azure disks with [LRS](https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy#redundancy-in-the-primary-region)
- [`premium-rwo`](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/azure/how-to/use-azure-disk.md.txt#premium): Provisions premium SSD Azure disks with LRS

## Before you begin

- [Connect to your cluster](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/azure/how-to/connect-and-authenticate-to-your-cluster.md.txt)

## Use the default StorageClass

When you create a PersistentVolumeClaim without setting the field
`spec.storageClassName`, GKE on Azure provisions an Azure
[Standard SSD volume](https://azure.microsoft.com/en-us/blog/preview-standard-ssd-disks-for-azure-virtual-machine-workloads/)
using the default GKE on Azure Azure Disk CSI Driver StorageClass.

The following YAML creates a PersistentVolumeClaim (PVC) named `mypvc` with a size
of 30 gibibytes.

```yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mypvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 30Gi
```

## Use the premium storage class

When you create a PersistentVolumeClaim and sed the field
`spec.storageClassName` to `premium-rwo`, GKE on Azure provisions an Azure
[premium SSD volume](https://azure.microsoft.com/en-us/blog/preview-standard-ssd-disks-for-azure-virtual-machine-workloads/).

The following YAML creates a PersistentVolumeClaim (PVC) named `mypvc` with a
size of 30 gibibytes.

```yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mypvc
spec:
  storageClassName: premium-rwo
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 30Gi
```

## Reference the StorageClass in a StatefulSet

To use your new StorageClass, you can reference it in a StatefulSet's
`volumeClaimTemplates`.

When you reference a StorageClass in a StatefulSet's `volumeClaimTemplates`
specification, Kubernetes provides stable storage using PersistentVolumes (PVs).
Kubernetes calls the provisioner defined in the StorageClass to create a new
storage volume. After the volume is provisioned, Kubernetes automatically
creates a PV.

The following StatefulSet references the `premium-rwo` StorageClass and
provisions a 1 gibibyte volume:

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: registry.k8s.io/nginx-slim:0.8
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates: # This is the specification in which you reference the StorageClass
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi
      storageClassName: premium-rwo # This field references the existing StorageClass
```

## What's next

- Read the documentation for the
  [Azure Disk CSI driver](https://github.com/kubernetes-sigs/azuredisk-csi-driver/tree/v1.8.0/docs).

- [Create a custom storage class](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/azure/how-to/storage-class.md.txt) with
  specific parameters.

- Learn about
  [Persistent volumes in GKE](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/persistent-volumes.md.txt).

- Install [Storage drivers](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/azure/how-to/storage-drivers.md.txt) on your GKE on Azure
  cluster.