Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Vorhandenes Azure Disk-Volumen importieren
Wenn Sie bereits ein Azure Disk-Volume haben, das mit GKE on Azure verwendet werden soll, können Sie ein PersistentVolume-Objekt (PV) erstellen und es für einen bestimmten PersistentVolumeClaim (PVC) reservieren.
Auf dieser Seite wird erläutert, wie Sie mithilfe eines vorhandenen, mit Daten gefüllten Volumes ein PV erstellen und in einem Pod verwenden.
VOLUME_CAPACITY: Größe des Volumes. Beispiel: 30Gi
Weitere Informationen zum Angeben der Volume-Kapazität in Kubernetes finden Sie unter Bedeutung des Arbeitsspeichers.
STORAGE_CLASS_NAME: Der Name der StorageClass, die das Volume bereitstellt.
Sie können beispielsweise den Standardwert standard-rwo verwenden.
SUBSCRIPTION_ID: die Azure-Abo-ID, die das Volume enthält.
RESOURCE_GROUP_NAME: die Azure-Ressourcengruppe, die das Volume enthält.
Die Ausgabe dieses Befehls enthält den Status des PV.
Volume mit einem PersistentVolumeClaim und einem Pod verwenden
Nachdem Sie das Volume importiert haben, können Sie einen PVC und einen Pod erstellen, der den PVC bereitstellt.
Mit der folgenden YAML-Datei wird ein PVC erstellt und an einen Pod angehängt, auf dem der Nginx-Webserver ausgeführt wird. Kopieren Sie ihn in eine Datei mit dem Namen nginx.yaml.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-22 (UTC)."],[],[],null,["# Import a preexisting Azure Disk volume\n======================================\n\nIf you already have an Azure Disk volume to use with\nGKE on Azure, you can create a PersistentVolume (PV) object and\nreserve it for a specific PersistentVolumeClaim (PVC).\n\nThis page explains how to create a PV by using an existing volume\npopulated with data, and how to use the PV in a Pod.\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\nCreate a PersistentVolume for a pre-existing volume\n---------------------------------------------------\n\nYou can import an existing volume by specifying a new PV.\n\n1. Copy the following YAML into a file named `existing-volume.yaml`.:\n\n apiVersion: v1\n kind: PersistentVolume\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_NAME\u003c/span\u003e\u003c/var\u003e\n annotations:\n pv.kubernetes.io/provisioned-by: disk.csi.azure.com\n spec:\n capacity:\n storage: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_CAPACITY\u003c/span\u003e\u003c/var\u003e\n accessModes:\n - ReadWriteOnce\n persistentVolumeReclaimPolicy: Retain\n storageClassName: \u003cvar 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 claimRef:\n name: my-pvc\n namespace: default\n csi:\n driver: disk.csi.azure.com\n volumeHandle: /subscriptions/\u003cvar translate=\"no\"\u003eSUBSCRIPTION_ID\u003c/var\u003e/resourcegroups/\u003cvar translate=\"no\"\u003eRESOURCE_GROUP_NAME\u003c/var\u003e/providers/microsoft.compute/disks/\u003cvar translate=\"no\"\u003eDISK_NAME\u003c/var\u003e\n fsType: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eFILE_SYSTEM_TYPE\u003c/span\u003e\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVOLUME_NAME\u003c/var\u003e: a name for the volume\n - \u003cvar translate=\"no\"\u003eVOLUME_CAPACITY\u003c/var\u003e: size of the volume. For example, `30Gi`. For more information on specifying volume capacity in Kubernetes, see the [Meaning of memory](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#meaning-of-memory).\n - \u003cvar translate=\"no\"\u003eSTORAGE_CLASS_NAME\u003c/var\u003e: the name of the StorageClass that\n provisions the volume.\n For example, you can use the default `standard-rwo`.\n\n | **Note:** A StorageClass is required to reference other attributes like `allowVolumeExpansion`, even if a volume is not dynamically provisioned.\n - \u003cvar translate=\"no\"\u003eSUBSCRIPTION_ID\u003c/var\u003e: the Azure subscription ID that contains the\n volume.\n\n - \u003cvar translate=\"no\"\u003eRESOURCE_GROUP_NAME\u003c/var\u003e: the Azure resource group that contains\n the volume.\n\n - \u003cvar translate=\"no\"\u003eDISK_NAME\u003c/var\u003e: the Azure Disk name of the volume.\n\n - \u003cvar translate=\"no\"\u003eFS_TYPE\u003c/var\u003e: the\n [file system type](https://github.com/kubernetes-sigs/azuredisk-csi-driver/blob/master/docs/driver-parameters.md#dynamic-provisioning)\n of the volume. For example, `ext4`.\n\n2. Apply the YAML to your cluster\n\n kubectl apply -f existing-volume.yaml\n\n3. Confirm the creation of your PV\n\n kubectl describe pv \u003cvar translate=\"no\"\u003eVOLUME_NAME\u003c/var\u003e\n\n The output of this command contains the status of the PV.\n\nUse the volume with a PersistentVolumeClaim and Pod\n---------------------------------------------------\n\nAfter you have imported your volume, you can create a PVC and a Pod that\nmounts the PVC.\n\n1. The following YAML creates a PVC and attaches it to a Pod running the Nginx web\n server. Copy it into a file named `nginx.yaml`:\n\n apiVersion: v1\n kind: PersistentVolumeClaim\n metadata:\n name: my-pvc\n spec:\n storageClassName: \u003cvar 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 volumeName: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_NAME\u003c/span\u003e\u003c/var\u003e\n accessModes:\n - \u003cvar 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 resources:\n requests:\n storage: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eVOLUME_CAPACITY\u003c/span\u003e\u003c/var\u003e\n ---\n\n apiVersion: v1\n kind: Pod\n metadata:\n name: web-server\n spec:\n containers:\n - name: web-server\n image: nginx\n volumeMounts:\n - mountPath: /var/lib/www/html\n name: data\n volumes:\n - name: data\n persistentVolumeClaim:\n claimName: my-pvc\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSTORAGE_CLASS\u003c/var\u003e: the name of the StorageClass from the PersistentVolume you created previously. For example, `standard-rwo`.\n - \u003cvar translate=\"no\"\u003eACCESS_MODE\u003c/var\u003e: the access mode of the volume. For Azure Disk, use `ReadWriteOnce`. For Azure File, use `ReadWriteMany`.\n - \u003cvar translate=\"no\"\u003eVOLUME_CAPACITY\u003c/var\u003e: size of the volume. For example, `30Gi`.\n2. Apply the YAML to your cluster\n\n kubectl apply -f nginx.yaml\n\n3. Check the status of your Nginx instance with `kubectl describe`. The output\n should have a `STATUS` of `Running`.\n\n kubectl describe pod web-server\n\nWhat's next\n-----------\n\n- Use additional [storage drivers](/kubernetes-engine/multi-cloud/docs/azure/how-to/storage-drivers) with GKE on Azure.\n- Read the documentation for the [Azure Disk CSI driver](https://github.com/kubernetes-sigs/azuredisk-csi-driver/tree/v1.8.0/docs)."]]