[[["容易理解","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-09-04 (世界標準時間)。"],[],[],null,["This document is intended for application owners and platform administrators\nthat run Google Distributed Cloud. This document shows you how to create and use\nstorage classes for VMs that use VM Runtime on GDC. A `StorageClass`\nlets you define different storage configurations to provide for the various\nneeds of your VMs.\n\nBefore you begin\n\nTo complete this document, you need access to Google Distributed Cloud version 1.12.0\n(`anthosBareMetalVersion: 1.12.0`) or higher cluster. You can use any cluster\ntype capable of running workloads. If needed,\n[try Google Distributed Cloud on Compute Engine](/kubernetes-engine/distributed-cloud/bare-metal/docs/try/gce-vms)\nor see the\n[cluster creation overview](/kubernetes-engine/distributed-cloud/bare-metal/docs/installing/creating-clusters/create-clusters-overview).\n\nStorage classes overview\n\nYou use a `StorageClass` to define the type of storage you make available to\nVMs. Different storage classes might map to a different type of storage\nhardware, file system, or performance. You can create and use storage classes to\nsupport your compute workloads in VM Runtime on GDC. For more\ninformation, see\n[Storage Classes](https://kubernetes.io/docs/concepts/storage/storage-classes/).\n\nA default `StorageClass` can be defined in the custom resource for\nVM Runtime on GDC. If you don't define a specific class when you\ncreate a `VirtualMachineDisks,` this default `StorageClass` is used. No initial\n`StorageClass` is configured and set as default. In the following section, you\nlearn how to\n[set or update this default StorageClass](#change-the-default-storageclass).\n\nSet or update the default StorageClass\n\nInitially, Google Distributed Cloud with VM Runtime on GDC have no default\n`StorageClass` configured. To create a `VirtualMachineDisk` without specifying a\n`StorageClass`, you must first\n[create a `StorageClass`](/kubernetes-engine/distributed-cloud/bare-metal/docs/installing/default-storage-class#create_storageclass)\nand then set it as default.\n\nIf you want to initially set or update the default `StorageClass` that\nVM Runtime on GDC uses when you create a `VirtualMachineDisk`, update\nthe `VMRuntime` custom resource.\n\n1. Edit the `VMRuntime` custom resource:\n\n kubectl edit vmruntime\n\n2. Add or update the `spec.storage` section that specifies the default\n `StorageClass` to use:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VMRuntime\n metadata:\n name: vmruntime\n spec:\n enabled: true\n storage:\n defaultStorageClass: \u003cvar label=\"storage_class_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSTORAGE_CLASS_NAME\u003c/span\u003e\u003c/var\u003e\n ...\n\n Edit \u003cvar translate=\"no\"\u003eSTORAGE_CLASS_NAME\u003c/var\u003e with the name of the default\n `StorageClass` you want to use. If you need to first create a `StorageClass`,\n see\n [Create a `StorageClass`](/kubernetes-engine/distributed-cloud/bare-metal/docs/installing/default-storage-class#create_storageclass).\n3. Save and close the `VMRuntime` custom resource in your editor.\n\n The `StorageClass` you specified is now used when you now create a virtual\n machine disk and don't specify a `StorageClass`. The following section shows\n you how to\n [create a disk and use a specific StorageClass](#use-a-specific-storageclass).\n\n Existing `VirtualMachineDisk` resources are not updated to use the newly\n specified `StorageClass`.\n\nUse a specific StorageClass\n\nIf you don't want to use the default `StorageClass` when you create a\n`VirtualMachineDisk`, use the `storageClassName` field to specify a different\n`StorageClass`.\n\nTo use a specific, already-defined `StorageClass` when you create a\n`VirtualMachineDisk`, complete the following steps:\n\n1. Create a `VirtualMachineDisk` manifest, such as `my-disk.yaml`, in the\n editor of your choice:\n\n nano my-disk.yaml\n\n2. Copy and paste the following YAML manifest:\n\n apiVersion: vm.cluster.gke.io/v1\n kind: VirtualMachineDisk\n metadata:\n name: \u003cvar label=\"disk_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDISK_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n size: 10Gi\n storageClassName: \u003cvar label=\"storage_class_name\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSTORAGE_CLASS_NAME\u003c/span\u003e\u003c/var\u003e\n\n Replace the following values:\n - \u003cvar translate=\"no\"\u003eDISK_NAME\u003c/var\u003e: the name for your disk.\n - \u003cvar translate=\"no\"\u003eSTORAGE_CLASS_NAME\u003c/var\u003e: the `StorageClass` to use for your disk. This `StorageClass` must already exist. If you need to first create a `StorageClass`, see [Create a StorageClass](/kubernetes-engine/distributed-cloud/bare-metal/docs/installing/default-storage-class#create_storageclass).\n3. Save and close the disk manifest in your editor.\n\n4. Create the disk using `kubectl`:\n\n kubectl apply -f my-disk.yaml\n\nConfigure storage profiles\n\nStorage profiles provide extra configuration options associated with each\n`StorageClass`. These configuration options include which access mode and volume\nmode to use for `VirtualMachineDisks` that use the `StorageClass`.\n\nWithout a configured storage profile, disks default to the `ReadWriteOnce`\naccess mode. This access mode isn't sufficient for production workloads, as\nfeatures like live migration don't work. The default volume mode without a\nconfigured storage profile is `Filesystem`.\n\nVM Runtime on GDC automatically generates one storage profile for\neach `StorageClass` in a cluster. The storage profile is the same name as the\nassociated `StorageClass`. The following example output shows that the cluster\nhas four storage classes and associated profiles: \n\n $ kubectl get storageprofiles\n\n NAME AGE\n anthos-system 11d\n node-disk 11d\n standard 11d\n nfs 11d\n\nTo edit a storage profile and change the access mode or volume mode, complete\nthe following steps:\n\n1. Edit the `StorageProfile` custom resource for editing:\n\n kubectl edit storageprofile \u003cvar label=\"access_mode\" translate=\"no\"\u003eSTORAGE_PROFILE_NAME\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eSTORAGE_PROFILE_NAME\u003c/var\u003e with the `StorageProfile`\n you want to edit.\n2. Add a single entry to the `spec.claimPropertySets` list of the\n `StorageProfile`:\n\n apiVersion: cdi.kubevirt.io/v1beta1\n kind: StorageProfile\n metadata:\n name: nfs\n spec:\n claimPropertySets:\n - accessModes:\n - \u003cvar label=\"access_mode\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eACCESS_MODE\u003c/span\u003e\u003c/var\u003e\n volumeMode: \u003cvar label=\"volume_mode\" translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_MODE\u003c/span\u003e\u003c/var\u003e\n\n The `accessMode` and `volumeMode` use the underlying Kubernetes components.\n The values you set depend on the storage driver you use. Replace the following\n values as appropriate for the storage you use:\n - \u003cvar translate=\"no\"\u003eACCESS_MODE\u003c/var\u003e: the access mode that you want to use. If supported by the associated `StorageClass`, the preferred access mode is `ReadWriteMany`.\n - Acceptable values include `ReadWriteOnce`, `ReadOnlyMany`, `ReadWriteMany`, and `ReadWriteOncePod`. If not specified, `ReadWriteOnce` is used based on the VM Runtime on GDC defaults. For more information, see [Access modes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes).\n - \u003cvar translate=\"no\"\u003eVOLUME_MODE\u003c/var\u003e: the volume mode that you want to use.\n - Acceptable values include `Filesystem` and `Block`. If not specified, `Filesystem` is used based on the Kubernetes defaults. For more information, see [Volume modes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-mode).\n\n | **Note:** The access mode and volume mode must be supported by the underlying `StorageClass`.\n3. Save and close the `StorageProfile` custom resource in your editor.\n\n The storage profile settings you defined are used when you now create any\n virtual disks. Existing `VirtualMachineDisk` resources are not updated to use\n the defined storage profile settings.\n\nWhat's next\n\n- [Create and manage disks in Google Distributed Cloud](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-manage-disks).\n- [Create and use credentials to import images from Cloud Storage](/kubernetes-engine/distributed-cloud/bare-metal/docs/vm-runtime/create-storage-credentials)."]]