[[["わかりやすい","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-30 UTC。"],[],[],null,["# Use dedicated Persistent Disks as ephemeral volumes\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview) [Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page shows you how to use external storage hardware, such as\nCompute Engine Persistent Disks, as ephemeral volumes in your\nGoogle Kubernetes Engine (GKE) workloads. You should already be familiar with\nKubernetes\n[Volumes](https://kubernetes.io/docs/concepts/storage/volumes/)\nand [StorageClasses](https://kubernetes.io/docs/concepts/storage/storage-classes/).\n\nWhen to use ephemeral storage in Kubernetes\n-------------------------------------------\n\nEphemeral storage is useful in any situation where your workloads only need the\ndata during the lifecycle of the application, such as for data-processing\npipelines, machine learning jobs, batch processing, local caching, or analytics.\nBy default, part of the GKE node boot disk is available to use as\nephemeral storage in your Pods. This approach often requires careful space planning.\n\nKubernetes\n[*generic ephemeral volumes*](https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#generic-ephemeral-volumes)\nlet you explicitly request ephemeral\nstorage for your Pods by using PersistentVolumeClaims. GKE\ndynamically provisions Compute Engine\n[Persistent Disks](/compute/docs/disks/persistent-disks) and attaches\nthe disks to your nodes. This type of ephemeral storage is useful in situations\nlike the following:\n\n- Your workloads have high performance requirements, so you need to control the storage hardware.\n- You need short-term, container-specific ephemeral storage.\n- You want to avoid using `emptyDir` to provision ephemeral storage. `emptyDir` volumes are still useful in situations where you want multiple containers to share the data in the ephemeral storage.\n- You want more ephemeral storage capacity than the GKE built-in defaults.\n- You want to avoid having to plan your node boot disk size and type in advance for Standard mode GKE clusters.\n\nEphemeral storage types in GKE\n------------------------------\n\nIn general, you can use boot disk storage capacity or dedicated\nPersistent Disks as ephemeral storage in your Pods and containers. The\nfollowing table describes the differences:\n\nPricing\n-------\n\nStorage that you provision through generic ephemeral volumes as described in\nthis guide is billed based on [Compute Engine disk pricing](/compute/all-pricing#disk).\n\nBefore you begin\n----------------\n\nBefore you start, make sure that you have performed the following tasks:\n\n- Enable the Google Kubernetes Engine API.\n[Enable Google Kubernetes Engine API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n- If you want to use the Google Cloud CLI for this task, [install](/sdk/docs/install) and then [initialize](/sdk/docs/initializing) the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running `gcloud components update`. **Note:** For existing gcloud CLI installations, make sure to set the `compute/region` [property](/sdk/docs/properties#setting_properties). If you use primarily zonal clusters, set the `compute/zone` instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: `One of [--zone, --region] must be supplied: Please specify location`. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.\n\n\u003c!-- --\u003e\n\n- Ensure that you have a GKE Autopilot or Standard cluster running version 1.23 or later.\n- Ensure that you have enough quota in your Google Cloud project for the storage hardware. To manage your quota, see [View and manage quotas](/docs/quotas/view-manage).\n\nCreate a StorageClass\n---------------------\n\nCreating a custom Kubernetes StorageClass lets you specify the type of storage\nto provision based on your price and performance requirements. This step is\noptional but recommended. If you want to use the GKE default\nStorageClass, which has the `pd-balanced` Persistent Disk type, skip this step.\n\n1. Save the following manifest as `ephemeral-pd-class.yaml`:\n\n apiVersion: storage.k8s.io/v1\n kind: StorageClass\n metadata:\n name: ephemeral-ssd\n provisioner: pd.csi.storage.gke.io\n volumeBindingMode: WaitForFirstConsumer\n allowVolumeExpansion: true\n parameters:\n type: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSTORAGE_TYPE\u003c/span\u003e\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eSTORAGE_TYPE\u003c/var\u003e with the name of the\n Persistent Disk type that you want, like `pd-ssd`. For a list of\n supported types, see [Persistent Disk types](/compute/docs/disks/persistent-disks#disk-types)\n in the Compute Engine documentation.\n2. Create the StorageClass:\n\n kubectl create -f ephemeral-pd-class.yaml\n\nRequest ephemeral storage capacity in a Pod\n-------------------------------------------\n\nTo provision, attach, and use external hardware as ephemeral storage, add the\ncorresponding volume to your Pod manifest and add a volume mount to the container\nspecification.\n\n1. Save the following manifest as `ephemeral-ssd-deployment.yaml`:\n\n apiVersion: apps/v1\n kind: Deployment\n metadata:\n name: ephemeral-deployment\n spec:\n replicas: 1\n selector:\n matchLabels:\n storage: ephemeral\n template:\n metadata:\n labels:\n storage: ephemeral\n spec:\n containers:\n - name: ephemeral-container\n image: nginx\n resources:\n requests:\n cpu: 500m\n memory: 2Gi\n ephemeral-storage: 2Gi\n volumeMounts:\n - mountPath: \"/short-term\"\n name: ephemeral-volume\n volumes:\n - name: ephemeral-volume\n ephemeral:\n volumeClaimTemplate:\n metadata:\n labels:\n type: ephemeral\n spec:\n accessModes: \\[\"ReadWriteOnce\"\\]\n storageClassName: \"ephemeral-ssd\"\n resources:\n requests:\n storage: 1Ti\n\n This manifest creates a new Kubernetes PersistentVolumeClaim that\n requests a new PersistentVolume named `ephemeral-volume` with the following\n properties:\n - **`spec.volumes.ephemeral`:** The `ephemeral` volume type.\n - **`.spec.accessModes`:** The volume access mode, which determines read-write access from Pods and volume sharing between nodes. This examples uses `ReadWriteOnce`, which mounts the PersistentVolume to a single node for access by one or more Pods on the node. For details, see [Access modes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes).\n - **`.spec.storageClassName`:** Optionally, the name of the StorageClass that you created. If you omit this field, GKE uses the default StorageClass and provisions a `pd-balanced` Persistent Disk.\n - **`.spec.resources.requests.storage`:** The storage capacity that you want.\n2. Create the Deployment:\n\n kubectl create -f ephemeral-ssd-deployment.yaml\n\nGKE provisions a Compute Engine disk that meets the\nrequirements of the PersistentVolumeClaim and attaches the disk to the node.\nGKE mounts the volume into the Pod and provides the requested capacity\nto the container.\n\nVerify that GKE mounted an ephemeral volume\n-------------------------------------------\n\n1. Create a shell session in the Pod:\n\n kubectl exec -it deploy/ephemeral-deployment -- bash\n\n2. Check the mounted volumes:\n\n df -h\n\n The output is similar to the following: \n\n Filesystem Size Used Available Use% Mounted on\n ...\n /dev/sdb 1006.9G 28.0K 1006.8G 0% /short-term\n /dev/sda1 94.3G 3.6G 90.6G 4% /etc/hosts\n /dev/sda1 94.3G 3.6G 90.6G 4% /dev/termination-log\n /dev/sda1 94.3G 3.6G 90.6G 4% /etc/hostname\n /dev/sda1 94.3G 3.6G 90.6G 4% /etc/resolv.conf\n ...\n\n3. Exit the shell session:\n\n exit\n\n| **Success:** You dynamically provisioned external storage hardware and mounted it to your Kubernetes workload as ephemeral storage.\n\nWhat's next\n-----------\n\n- [Learn about the available storage options in GKE](/kubernetes-engine/docs/concepts/storage-overview)"]]