Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina spiega come creare una copia, o snapshot, di un volume di archiviazione in un
momento specifico per l'applicazione container. Uno snapshot del volume ti consente
di riportare un volume a uno stato precedente o di eseguire il provisioning di un nuovo volume.
Questa pagina è rivolta agli sviluppatori del gruppo di operatori di applicazioni, che sono
responsabili della creazione dei carichi di lavoro delle applicazioni per la propria organizzazione.
Prima di iniziare
Per eseguire comandi sul cluster Kubernetes bare metal preconfigurato, assicurati di disporre delle seguenti risorse:
Individua il nome del cluster Kubernetes o chiedi all'amministratore della piattaforma qual è il nome del cluster.
Accedi e genera il file kubeconfig per il cluster Kubernetes se non ne hai uno.
Utilizza il percorso kubeconfig del cluster Kubernetes per sostituire
CLUSTER_KUBECONFIG in queste istruzioni.
Per ottenere le autorizzazioni necessarie per gestire gli snapshot dei volumi, chiedi all'amministratore IAM dell'organizzazione di concederti il ruolo Amministratore namespace (namespace-admin) nel namespace del progetto.
Acquisire uno snapshot del volume
Per creare uno snapshot di un oggetto PersistentVolumeClaim, crea un oggetto VolumeSnapshot. Il sistema non garantisce la coerenza dei dati. Metti in pausa
l'applicazione e svuota i dati prima di acquisire uno snapshot.
CLUSTER_KUBECONFIG: il file kubeconfig per il cluster Kubernetes.
NAMESPACE: lo spazio dei nomi del progetto in cui creare lo snapshot del volume.
VOLUME_SNAPSHOT_NAME: il nome dell'oggetto
VolumeSnapshot.
PVC_NAME: il nome del PVC per cui stai creando uno snapshot.
L'operazione di snapshot viene completata quando il campo .status.readyToUse
diventa true. Puoi utilizzare il seguente comando per controllare lo stato:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-05 UTC."],[[["\u003cp\u003eVolume snapshots allow you to create a copy of a volume at a specific point in time, which can be used to restore a volume to a previous state or provision a new one.\u003c/p\u003e\n"],["\u003cp\u003eIn Kubernetes, volume snapshots are managed through the \u003ccode\u003eVolumeSnapshot\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eBefore managing volume snapshots, you need to ensure you have the user cluster name, a kubeconfig file for that cluster, and the Namespace Admin role permissions.\u003c/p\u003e\n"],["\u003cp\u003eTo create a snapshot of a \u003ccode\u003ePersistentVolumeClaim\u003c/code\u003e, you need to create a \u003ccode\u003eVolumeSnapshot\u003c/code\u003e object, while pausing the application and flushing data prior to the snapshot.\u003c/p\u003e\n"],["\u003cp\u003eYou can verify the completion of the snapshot operation by checking if the \u003ccode\u003e.status.readyToUse\u003c/code\u003e field becomes \u003ccode\u003etrue\u003c/code\u003e, and then you can update the PVC manifest using the snapshot as a data source.\u003c/p\u003e\n"]]],[],null,["# Create volume snapshots\n\nThis page explains how to create a copy, or snapshot, of a storage volume at a\nspecific point in time for your container application. A volume snapshot lets\nyou bring a volume back to a prior state or provision a new volume.\n\nThis page is for developers within the application operator group, who are\nresponsible for creating application workloads for their organization.\n\nBefore you begin\n----------------\n\nTo run commands against the pre-configured bare metal Kubernetes cluster, make sure you have the\nfollowing resources:\n\n1. Locate the Kubernetes cluster name, or ask your Platform\n Administrator what the cluster name is.\n\n2. [Sign in and generate](/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/iam/sign-in#kubernetes-cluster-kubeconfig) the\n kubeconfig file for the Kubernetes cluster if you don't have one.\n\n3. Use the kubeconfig path of the Kubernetes cluster to replace\n \u003cvar translate=\"no\"\u003eCLUSTER_KUBECONFIG\u003c/var\u003e in these instructions.\n\nTo get the required permissions to manage volume snapshots, ask your\nOrganization IAM Admin to grant you the Namespace Admin role (`namespace-admin`)\nin your project namespace.\n\nTake a volume snapshot\n----------------------\n\nTo take a snapshot of a `PersistentVolumeClaim` object, create a\n`VolumeSnapshot` object. The system does not guarantee data consistency. Pause\nthe application and flush data before taking a snapshot.\n\n1. Create a `VolumeSnapshot` custom resource:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eCLUSTER_KUBECONFIG\u003c/var\u003e \\\n --namespace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: snapshot.storage.k8s.io/v1\n kind: VolumeSnapshot\n metadata:\n name: \u003cvar translate=\"no\"\u003eVOLUME_SNAPSHOT_NAME\u003c/var\u003e\n spec:\n source:\n persistentVolumeClaimName: \u003cvar translate=\"no\"\u003ePVC_NAME\u003c/var\u003e\n EOF\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for\n the Kubernetes cluster.\n\n - \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the project namespace in which to create the\n volume snapshot.\n\n - \u003cvar translate=\"no\"\u003eVOLUME_SNAPSHOT_NAME\u003c/var\u003e: the `VolumeSnapshot` object\n name.\n\n - \u003cvar translate=\"no\"\u003ePVC_NAME\u003c/var\u003e: the name of the PVC for which you are\n creating a snapshot.\n\n2. The snapshot operation is complete when the `.status.readyToUse` field\n becomes `true`. You can use the following command to check the status:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eCLUSTER_KUBECONFIG\u003c/var\u003e get volumesnapshot \\\n -o custom-columns='NAME:.metadata.name,READY:.status.readyToUse'\n\n3. Update the PVC manifest with the volume snapshot specified as a data\n source:\n\n kubectl --kubeconfig \u003cvar translate=\"no\"\u003eCLUSTER_KUBECONFIG\u003c/var\u003e \\\n --namespace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e apply -f - \u003c\u003cEOF\n apiVersion: v1\n kind: PersistentVolumeClaim\n metadata:\n name: \u003cvar translate=\"no\"\u003ePVC_NAME\u003c/var\u003e\n spec:\n dataSource:\n name: \u003cvar translate=\"no\"\u003eVOLUME_SNAPSHOT_NAME\u003c/var\u003e\n kind: VolumeSnapshot\n apiGroup: snapshot.storage.k8s.io\n storageClassName: standard-rwo\n accessModes:\n - ReadWriteOnce\n resources:\n requests:\n storage: 10Gi\n EOF\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCLUSTER_KUBECONFIG\u003c/var\u003e: the kubeconfig file for\n the Kubernetes cluster.\n\n - \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the namespace in which the PVC\n resource exists.\n\n - \u003cvar translate=\"no\"\u003ePVC_NAME\u003c/var\u003e: the name of the PVC for which you are\n creating a snapshot.\n\n - \u003cvar translate=\"no\"\u003eVOLUME_SNAPSHOT_NAME\u003c/var\u003e: the name of the volume\n snapshot.\n\nWhat's next\n-----------\n\n- [Container workloads overview](/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/containers/containers-intro)\n- [Create stateful workloads](/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/containers/create-stateful-workloads)\n- [Access persistent storage](/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/containers/access-persistent-storage)"]]