In diesem Dokument wird erläutert, wie Sie mit dem StatefulSet-CSI-Migrationstool zustandsorientierte Arbeitslasten von einem integrierten vSphere-Volume-Plug-in zum vSphere-CSI-Treiber in GKE on VMware migrieren.
Überblick
GKE on VMware lässt sich über VMware vSphere-Speicher, integrierte Kubernetes-Volume-Plug-ins (oder „Treiber“) und CSI-Treiber (Container Storage Interface) in externe Block- oder Dateispeichersysteme einbinden.
Wenn das CSI-Migrationsfeature von Kubernetes in 1.15 standardmäßig aktiviert ist, funktioniert ein vom integrierten vSphere-Volume-Plug-in unterstütztes nichtflüchtiges Volume weiterhin in einer reinen CSI-Umgebung. Die CSI-Migrationsfunktion leitet vorhandene Plug-in-Vorgangsaufrufe an den CSI-Treiber weiter. Da die Persistent-Spezifikation unveränderlich ist, wird sie weiterhin vom integrierten Plug-in unterstützt. Die verfügbaren Features sind dieselben wie beim integrierten Volume-Plug-in.
Für solche Volumes ist nicht der vollständige Satz von CSI-Features wie Volume-Erweiterung und Volume-Snapshot verfügbar. Damit Sie diese Features nutzen können, müssen zustandsorientierte Arbeitslasten vollständig zu CSI migriert werden. Dazu müssen Sie die vom vSphere-CSI-Treiber unterstützten nichtflüchtige Speicher neu erstellen. Mit dem CSI-Migrationstool können Sie zustandsorientierte Arbeitslasten zu CSI migrieren und alle CSI-Features nutzen.
Dieses Tool bietet eine Möglichkeit zum rollierenden Migrieren des StatefulSets und des StatefulSets in CSI. Es kommt nicht zu Ausfallzeiten der Anwendung. Dieses Tool erstellt die Sicherung von Kubernetes-Ressourcen in einem lokalen Verzeichnis und setzt ReclaimPolicy vor der Migration auf Retain. Es gibt also keinen Datenverlust.
Beschränkung
Die automatisierten Tools werden nur in GKE in VMware-Versionen unterstützt, die vollständig unterstützt werden.
Er funktioniert nur mit StatefulSets. Sie können mit dem Tool Preflight-Prüfungen ausführen, bevor Sie die Tools verwenden.
ADMIN_KUBECONFIG: der Pfad der kubeconfig-Datei Ihres Administratorclusters.
USER_CLUSTER_NAME: Wenn das StatefulSet auf dem Nutzercluster ausgeführt wird, geben Sie den Namen des Nutzerclusters an.
Überspringen Sie dieses Flag, wenn die Arbeitslast auf dem Administratorcluster ausgeführt wird.
STS_NAME ist der Name des StatefulSets.
STS_NAMESPACE: Namespace des StatefulSets.
INTREE_STORAGECLASS: der Name der integrierten Speicherklasse, der das StatefulSet des StatefulSets unterstützt.
CSI_STORAGECLASS: Der Name der CSI-Speicherklasse, der das StatefulSet des StatefulSets nach der Migration sichert.
Herunterladen
Laden Sie das Tool unter gs://gke-on-prem-release/statefulset-csi-migration-tool/v0.1/statefulset-csi-migration-tool herunter.
Hinweis: Dieses Tool befindet sich in der Vorschau.
Prozedur
In diesem Abschnitt werden die Schritte beschrieben, die für die Migration von StatefulSet vom internen vCP-Bereitsteller (kubernetes.io/vsphere-volume) von vSphere zum CSI-Bereitsteller (csi.vsphere.vmware.com) von vSphere erforderlich sind.
ADMIN_KUBECONFIG: der Pfad der kubeconfig-Datei Ihres Administratorclusters.
USER_CLUSTER_NAME: Wenn das StatefulSet auf dem Nutzercluster ausgeführt wird, geben Sie den Namen des Nutzerclusters an.
Überspringen Sie dieses Flag, wenn die Arbeitslast auf dem Administratorcluster ausgeführt wird.
STS_NAME ist der Name des StatefulSets.
STS_NAMESPACE: Namespace des StatefulSets.
INTREE_STORAGECLASS: der Name der integrierten Speicherklasse, der das StatefulSet des StatefulSets unterstützt.
CSI_STORAGECLASS: Der Name der CSI-Speicherklasse, der das StatefulSet des StatefulSets nach der Migration sichert.
WORKING_DIRECTORY: das lokale Verzeichnis, in dem die Kubernetes-Ressourcenspezifikation des StatefulSets und des zugehörigen Pods, nichtflüchtiger Anspruch und nichtflüchtiger Speicher gespeichert werden soll. Der Verzeichnisname muss für jedes StatefulSet eindeutig sein. Dieses Verzeichnis sollte leer oder nicht vorhanden sein.
Es empfiehlt sich, dieses Verzeichnis nicht zu erstellen, damit die Tools eines für Sie erstellen können.
Mit diesem Befehl werden die folgenden Aufgaben ausgeführt:
Sie erstellt im lokalen Arbeitsverzeichnis eine Sicherung des StatefulSets und seiner Abhängigkeiten, z. B. nichtflüchtiger Speicher, nichtflüchtiger Anspruch und Pod-Replikatspezifikationen.
Löscht das StatefulSet mit der Richtlinie für verwaiste Elemente. Mit diesem Schritt wird nur das StatefulSet gelöscht, jedoch nicht die zugehörigen Abhängigkeiten wie die Pod-Replikate, nichtflüchtiger Speicher und nichtflüchtiger Anspruch.
Migriert jeden Pod zu CSI-Treibern (ähnlich wie Option 1) und führt Folgendes aus:
a. Legt das Feld "ReclaimPolicy" des Persistentes als "Halten" fest.
b. Löscht den Pod, das nichtflüchtige Volume und PersistentVolumeClaim.
c. Konvertiert das vorhandene VMDK in FCD.
d. Erstellt das nichtflüchtige Speichermedium, den PersistentVolumeClaim und den Pod noch einmal.
Sie erstellt das StatefulSet neu, wobei das PVCTemplate-Feld in seiner Spezifikation auf die CSI-Speicherklasse verweist. Der StatefulSet-Controller sollte den verwaisten Replikaten wieder zugeordnet werden.
[[["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-09-04 (UTC)."],[[["\u003cp\u003eThis tool facilitates the migration of stateful workloads from in-tree vSphere volume plugins to the vSphere CSI Driver in Google Distributed Cloud, enabling the use of full CSI features.\u003c/p\u003e\n"],["\u003cp\u003eThe StatefulSet CSI Migration Tool supports rolling migration of a StatefulSet's PersistentVolume and PersistentVolumeClaim to CSI without application downtime, backing up resources and setting \u003ccode\u003eReclaimPolicy\u003c/code\u003e to \u003ccode\u003eRetain\u003c/code\u003e to prevent data loss.\u003c/p\u003e\n"],["\u003cp\u003eThe automated tooling is compatible only with fully supported Google Distributed Cloud versions and is exclusively designed for use with StatefulSets.\u003c/p\u003e\n"],["\u003cp\u003eBefore migration, the tool offers preflight checks to ensure safety, requiring parameters such as admin cluster kubeconfig, cluster name, StatefulSet name, namespace, in-tree, and CSI StorageClass names.\u003c/p\u003e\n"],["\u003cp\u003eThe migration process involves backing up resources, deleting the StatefulSet, migrating each Pod to CSI drivers, converting VMDKs to FCDs, recreating resources with the CSI StorageClass, and re-establishing the StatefulSet with the migrated components.\u003c/p\u003e\n"]]],[],null,["# Using the StatefulSet CSI Migration Tool\n\n\u003cbr /\u003e\n\n|\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document explains how to use the StatefulSet CSI Migration Tool to\nmigrate stateful workloads from an in-tree vSphere volume plugin to the vSphere\nCSI Driver in Google Distributed Cloud.\n\nOverview\n--------\n\nGoogle Distributed Cloud integrates with external block or file storage systems\nthrough VMware vSphere storage, Kubernetes in-tree volume plugins (or\n\"drivers\"), and Container Storage Interface (CSI) drivers.\n\nWith the Kubernetes CSI migration feature enabled by default in 1.15, a\nPersistentVolume backed by the in-tree vSphere volume plugin continues\nfunctioning in a CSI-only environment. The CSI migration feature redirects\nin-tree plugin operation calls to the CSI driver. Because the PersistentVolume\nspec is immutable, it is still backed by the in-tree plugin. The set of\navailable features is the same as for the in-tree volume plugin.\n\nThe full set of CSI features, like Volume Expansion and Volume Snapshot,\nisn't available for such volumes. To take advantage of these features,\nstateful workloads must be completely migrated to CSI by recreating the\nPersistentVolumes backed by the vSphere CSI Driver. You can use the\nCSI migration tool to migrate stateful workloads to CSI and use the full set of\nCSI features.\n\nThis tool provides a way to rolling migrate a StatefulSet's PersistentVolume and\nPersistentVolumeClaim to CSI and does not involve application downtime. This\ntooling takes the backup of Kubernetes resources in a local directory and sets\n`ReclaimPolicy` to `Retain` before migration. So there will be no data loss.\n\nLimitation\n----------\n\n- The automated tooling is only supported on Google Distributed Cloud versions that\n are [fully supported](/anthos/clusters/docs/on-prem/1.16//version-history).\n\n- It only works with StatefulSets. You can run preflight checks using\n the tool to run a few safety checks before using the tools.\n\n```\n./statefulset-csi-migration-tool preflight \\\n --kubeconfig ADMIN_KUBECONFIG \\\n --cluster-name USER_CLUSTER_NAME \\\n --sts-name STS_NAME \\\n --sts-namespace STS_NAMESPACE \\\n --intree-storageclass INTREE_STORAGECLASS \\\n --csi-storageclass CSI_STORAGECLASS\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eADMIN_KUBECONFIG\u003c/var\u003e: the path of your admin cluster\n kubeconfig file.\n\n- \u003cvar translate=\"no\"\u003eUSER_CLUSTER_NAME\u003c/var\u003e: If the StatefulSet is\n running on the user cluster, then provide the user cluster name.\n Skip this flag if the workload is running on the admin cluster.\n\n- \u003cvar translate=\"no\"\u003eSTS_NAME\u003c/var\u003e: name of the StatefulSet.\n\n- \u003cvar translate=\"no\"\u003eSTS_NAMESPACE\u003c/var\u003e: namespace of the StatefulSet.\n\n- \u003cvar translate=\"no\"\u003eINTREE_STORAGECLASS\u003c/var\u003e: the in-tree StorageClass\n name backing the StatefulSet's PersistentVolume.\n\n- \u003cvar translate=\"no\"\u003eCSI_STORAGECLASS\u003c/var\u003e: the CSI StorageClass\n name backing the StatefulSet's PersistentVolume after migration.\n\nDownload\n--------\n\nDownload the tool at\n`gs://gke-on-prem-release/statefulset-csi-migration-tool/v0.1/statefulset-csi-migration-tool`.\nNote this tool is in preview.\n\nProcedure\n---------\n\nThis section provides the steps needed for migrating StatefulSet from vSphere\nin-tree **vCP** internal provisioner (`kubernetes.io/vsphere-volume`) to vSphere\n**CSI** provisioner (`csi.vsphere.vmware.com`). \n\n```\n./statefulset-csi-migration-tool rolling-migration all \\\n --kubeconfig ADMIN_KUBECONFIG \\\n --cluster-name USER_CLUSTER_NAME \\\n --sts-name STS_NAME \\\n --sts-namespace STS_NAMESPACE \\\n --intree-storageclass INTREE_STORAGECLASS \\\n --csi-storageclass CSI_STORAGECLASS \\\n --working-directory WORKING_DIRECTORY\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eADMIN_KUBECONFIG\u003c/var\u003e: the path of your admin cluster\n kubeconfig file.\n\n- \u003cvar translate=\"no\"\u003eUSER_CLUSTER_NAME\u003c/var\u003e: If the StatefulSet is\n running on the user cluster, then provide the user cluster name.\n Skip this flag if the workload is running on the admin cluster.\n\n- \u003cvar translate=\"no\"\u003eSTS_NAME\u003c/var\u003e: name of the StatefulSet.\n\n- \u003cvar translate=\"no\"\u003eSTS_NAMESPACE\u003c/var\u003e: namespace of the StatefulSet.\n\n- \u003cvar translate=\"no\"\u003eINTREE_STORAGECLASS\u003c/var\u003e: the in-tree StorageClass\n name backing the StatefulSet's PersistentVolume.\n\n- \u003cvar translate=\"no\"\u003eCSI_STORAGECLASS\u003c/var\u003e: the CSI StorageClass\n name backing the StatefulSet's PersistentVolume after migration.\n\n- \u003cvar translate=\"no\"\u003eWORKING_DIRECTORY\u003c/var\u003e: the local directory to\n save the Kubernetes resource spec of StatefulSet and its Pod,\n PersistentVolumeClaim and PersistentVolume. The directory name must be\n unique for each StatefulSet. This directory should be empty or not exist.\n It is ideal to not create this directory so that the tooling can create\n one for you.\n\nThis command performs the following tasks:\n\n1. Takes a backup of the StatefulSet and its dependencies like PersistentVolume,\n PersistentVolumeClaim and Pod replica specs in the local working directory.\n\n2. Deletes the StatefulSet with orphan deletion policy. This step only deletes\n the StatefulSet but does not delete its dependencies like the Pod replicas,\n PersistentVolume and PersistentVolumeClaim.\n\n3. Migrates each Pod to CSI drivers (similar to Option 1), and does the\n following:\n\n a. Sets the PersistentVolume's ReclaimPolicy field as Retain.\n\n b. Deletes the Pod, PersistentVolume and PersistentVolumeClaim.\n\n c. Converts the existing VMDK to FCD.\n\n d. Creates the PersistentVolume, PersistentVolumeClaim and Pod again.\n4. Recreates the StatefulSet, but the PVCTemplate field in its spec points to\n the CSI StorageClass. The StatefulSet controller should map to the orphaned\n replicas again."]]