Use an Azure Disk volume
GKE on Azure automatically deploys the
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.
Default storage classes
GKE on Azure provides the following StorageClass options by default:
standard-rwo
(default): Provisions standard SSD Azure disks with LRSpremium-rwo
: Provisions premium SSD Azure disks with LRS
Before you begin
Use the default StorageClass
When you create a PersistentVolumeClaim without setting the field
spec.storageClassName
, GKE on Azure provisions an Azure
Standard SSD volume
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.
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.
The following YAML creates a PersistentVolumeClaim (PVC) named mypvc
with a
size of 30 gibibytes.
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:
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.
Create a custom storage class with specific parameters.
Learn about Persistent volumes in GKE.
Install Storage drivers on your GKE on Azure cluster.