建立 PersistentVolumeClaim 時,如果未設定 spec.storageClassName 欄位,GKE on Azure 會使用預設的 GKE on Azure Azure Disk CSI Driver StorageClass,佈建 Azure Standard SSD 磁碟區。
apiVersion:apps/v1kind:StatefulSetmetadata:name:webspec:selector:matchLabels:app:nginxtemplate:metadata:labels:app:nginxspec:containers:-name:nginximage:registry.k8s.io/nginx-slim:0.8volumeMounts:-name:wwwmountPath:/usr/share/nginx/htmlvolumeClaimTemplates:# This is the specification in which you reference the StorageClass-metadata:name:wwwspec:accessModes:["ReadWriteOnce"]resources:requests:storage:1GistorageClassName:premium-rwo# This field references the existing StorageClass
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-22 (世界標準時間)。"],[],[],null,["# Use an Azure Disk volume\n========================\n\nGKE on Azure automatically deploys the\n[`azuredisk-csi-driver`](https://github.com/kubernetes-sigs/azuredisk-csi-driver)\nto provision and manage Azure Disk volumes in your clusters.\n\nThe GKE on Azure Azure Disk CSI Driver version is tied to a Kubernetes cluster\nversion. The driver version is typically the latest available when the\nGKE version is released. When the cluster is upgraded, the\ndrivers update automatically.\n\nFor more information on how GKE on Azure provides persistent storage,\nsee [Storage overview](/kubernetes-engine/multi-cloud/docs/azure/concepts/storage).\n\nDefault storage classes\n-----------------------\n\nGKE on Azure provides the following StorageClass options by default:\n\n- [`standard-rwo`](#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)\n- [`premium-rwo`](#premium): Provisions premium SSD Azure disks with LRS\n\nBefore you begin\n----------------\n\n- [Connect to your cluster](/kubernetes-engine/multi-cloud/docs/azure/how-to/connect-and-authenticate-to-your-cluster)\n\nUse the default StorageClass\n----------------------------\n\nWhen you create a PersistentVolumeClaim without setting the field\n`spec.storageClassName`, GKE on Azure provisions an Azure\n[Standard SSD volume](https://azure.microsoft.com/en-us/blog/preview-standard-ssd-disks-for-azure-virtual-machine-workloads/)\nusing the default GKE on Azure Azure Disk CSI Driver StorageClass.\n\nThe following YAML creates a PersistentVolumeClaim (PVC) named `mypvc` with a size\nof 30 gibibytes. \n\n apiVersion: v1\n kind: PersistentVolumeClaim\n metadata:\n name: mypvc\n spec:\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: 30Gi\n\nUse the premium storage class\n-----------------------------\n\nWhen you create a PersistentVolumeClaim and sed the field\n`spec.storageClassName` to `premium-rwo`, GKE on Azure provisions an Azure\n[premium SSD volume](https://azure.microsoft.com/en-us/blog/preview-standard-ssd-disks-for-azure-virtual-machine-workloads/).\n\nThe following YAML creates a PersistentVolumeClaim (PVC) named `mypvc` with a\nsize of 30 gibibytes. \n\n apiVersion: v1\n kind: PersistentVolumeClaim\n metadata:\n name: mypvc\n spec:\n storageClassName: premium-rwo\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: 30Gi\n\nReference the StorageClass in a StatefulSet\n-------------------------------------------\n\nTo use your new StorageClass, you can reference it in a StatefulSet's\n`volumeClaimTemplates`.\n\nWhen you reference a StorageClass in a StatefulSet's `volumeClaimTemplates`\nspecification, Kubernetes provides stable storage using PersistentVolumes (PVs).\nKubernetes calls the provisioner defined in the StorageClass to create a new\nstorage volume. After the volume is provisioned, Kubernetes automatically\ncreates a PV.\n\nThe following StatefulSet references the `premium-rwo` StorageClass and\nprovisions a 1 gibibyte volume: \n\n apiVersion: apps/v1\n kind: StatefulSet\n metadata:\n name: web\n spec:\n selector:\n matchLabels:\n app: nginx\n template:\n metadata:\n labels:\n app: nginx\n spec:\n containers:\n - name: nginx\n image: registry.k8s.io/nginx-slim:0.8\n volumeMounts:\n - name: www\n mountPath: /usr/share/nginx/html\n volumeClaimTemplates: # This is the specification in which you reference the StorageClass\n - metadata:\n name: www\n spec:\n accessModes: [ \"ReadWriteOnce\" ]\n resources:\n requests:\n storage: 1Gi\n storageClassName: premium-rwo # This field references the existing StorageClass\n\nWhat's next\n-----------\n\n- Read the documentation for the\n [Azure Disk CSI driver](https://github.com/kubernetes-sigs/azuredisk-csi-driver/tree/v1.8.0/docs).\n\n- [Create a custom storage class](/kubernetes-engine/multi-cloud/docs/azure/how-to/storage-class) with\n specific parameters.\n\n- Learn about\n [Persistent volumes in GKE](/kubernetes-engine/docs/concepts/persistent-volumes).\n\n- Install [Storage drivers](/kubernetes-engine/multi-cloud/docs/azure/how-to/storage-drivers) on your GKE on Azure\n cluster."]]