# fast-sc.yamlapiVersion:storage.k8s.io/v1kind:StorageClassmetadata:name:premium-rwoprovisioner:csi.example.com# CSI driverparameters:# You provide vendor-specific parameters to this specificationtype:example-parameter# Be sure to follow the vendor's instructionsdatastore:my-datastorereclaimPolicy:RetainallowVolumeExpansion:true
# statefulset.yamlapiVersion:apps/v1kind:StatefulSetmetadata:name:webspec:replicas:2selector: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"]],["最后更新时间 (UTC):2025-09-03。"],[],[],null,["# Manually install a CSI driver\n\n[Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page explains how to install a Container Storage Interface (CSI) storage\ndriver on Google Kubernetes Engine (GKE) Standard clusters. This page\ndoesn't apply to GKE Autopilot clusters, which\nautomatically use the\n[Compute Engine persistent disk CSI driver](/kubernetes-engine/docs/how-to/persistent-volumes/gce-pd-csi-driver#using_the_for_linux_clusters).\n\nIf you are using the\n[Compute Engine persistent disk CSI driver](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver) in your\nStandard cluster, we recommend\n[automatically deploying the driver](/kubernetes-engine/docs/how-to/persistent-volumes/gce-pd-csi-driver)\nto reduce your management overhead.\n\nOverview\n--------\n\n[CSI](https://github.com/container-storage-interface/spec/blob/master/spec.md)\nis an open standard API that enables Kubernetes to expose arbitrary storage\nsystems to containerized workloads. Kubernetes volumes are managed by\nvendor-specific storage drivers, which have historically been\n[compiled into Kubernetes binaries](https://kubernetes.io/docs/concepts/storage/volumes/#types-of-volumes).\nPreviously, you could not use a storage driver that was not included with\nKubernetes. Installing a CSI driver adds support for a storage system that is\nnot natively supported by Kubernetes. Also, CSI enables the use of modern\nstorage features, such as snapshots and resizing.\n| **Note:** Google Distributed Cloud 1.5 does not support Kubernetes CSI snapshots.\n\nInstalling a vendor's CSI driver\n--------------------------------\n\nOther storage vendors develop their own CSI drivers, and they are responsible for\nproviding installation instructions. In simple cases, installation might only\ninvolve deploying manifests to your clusters. See the list of [CSI\ndrivers](https://kubernetes-csi.github.io/docs/drivers.html) in the\nCSI documentation.\n| **Note:** Google does not provide support for, nor instructions for installing, other vendors' drivers.\n\nVerifying a driver installation\n-------------------------------\n\nAfter you install a CSI driver, you can verify the installation by running one\nof the following commands, depending on your cluster's GKE\nversion: \n\n### 1.14+\n\n```\nkubectl get csinodes \\\n-o jsonpath='{range .items[*]} {.metadata.name}{\": \"} {range .spec.drivers[*]} {.name}{\"\\n\"} {end}{end}'\n```\n\n### 1.13.x\n\n```\nkubectl get nodes \\\n-o jsonpath='{.items[*].metadata.annotations.csi\\.volume\\.kubernetes\\.io\\/nodeid}'\n```\n\nUsing a CSI driver\n------------------\n\nTo use a CSI driver:\n\n1. Create a Kubernetes [StorageClass](https://kubernetes.io/docs/concepts/storage/storage-classes/)\n that references the driver in its `provisioner` field, if a StorageClass is\n not created for you as part of driver installation. Some CSI drivers deploy\n a StorageClass when you install them.\n\n2. To provision storage, you can either:\n\n - Reference the StorageClass in the `volumeClaimTemplates` specification for a [StatefulSet](/kubernetes-engine/docs/concepts/statefulset) object.\n - [Set it as the cluster's default StorageClass](https://kubernetes.io/docs/tasks/administer-cluster/change-default-storage-class/).\n\n### Considerations for StorageClasses backed by a CSI driver\n\nWhen you create a StorageClass, consider the following:\n\n- CSI driver documentation should include the [driver-specific parameters](https://kubernetes.io/docs/concepts/storage/storage-classes/#the-storageclass-resource) that you provide to your StorageClass, including the provisioner name.\n- You should name the StorageClass after its properties, rather than after the name of the specific driver or appliance behind it. Naming the StorageClass after its properties allows you to create StorageClasses with the same name across multiple clusters and environments, and allows your applications to get storage with the same properties across clusters.\n\n### Example: Reference StorageClass in a StatefulSet\n\nThe following example models how to define a CSI driver in a StorageClass, and\nthen reference the StorageClass in a [StatefulSet](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)\nworkload. The example assumes the driver has already been installed to the\ncluster.\n\nThe following is a simple StorageClass named `premium-rwo` that uses a fictional\nCSI driver, `csi.example.com`, as its provisioner: \n\n # fast-sc.yaml\n apiVersion: storage.k8s.io/v1\n kind: StorageClass\n metadata:\n name: premium-rwo\n provisioner: csi.example.com # CSI driver\n parameters: # You provide vendor-specific parameters to this specification\n type: example-parameter # Be sure to follow the vendor's instructions\n datastore: my-datastore\n reclaimPolicy: Retain\n allowVolumeExpansion: true\n\nYou reference the StorageClass in a StatefulSet's `volumeClaimTemplates`\nspecification.\n\nWhen you reference a StorageClass in a StatefulSet's `volumeClaimTemplates`\nspecification, Kubernetes provides stable storage using PersistentVolumes.\nKubernetes calls the provisioner defined in the StorageClass to create a new\nstorage volume. In this case, Kubernetes calls the fictional `csi.example.com`\nprovider, which calls out to the provider's API, to create a volume. After the\nvolume is provisioned, Kubernetes automatically creates a PersistentVolume to\nrepresent the storage.\n\nHere is a simple StatefulSet that references the StorageClass: \n\n # statefulset.yaml\n apiVersion: apps/v1\n kind: StatefulSet\n metadata:\n name: web\n spec:\n replicas: 2\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- Learn more about GKE [storage concepts](/kubernetes-engine/docs/concepts/storage-overview)."]]