Įvykiai
03-31 23 - 04-02 23
Didžiausias "Fabric", Power BI ir SQL mokymosi įvykis. Kovo 31 d. – balandžio 2 d. Naudokite kodą FABINSIDER, kad įrašytumėte $400.
Registruokitės šiandienŠi naršyklė nebepalaikoma.
Atnaujinkite į „Microsoft Edge“, kad pasinaudotumėte naujausiomis funkcijomis, saugos naujinimais ir techniniu palaikymu.
Azure Container Storage is a cloud-based volume management, deployment, and orchestration service built natively for containers. This article shows you how to take a point-in-time snapshot of a persistent volume and restore it with a new persistent volume claim.
First, create a volume snapshot class, which allows you to specify the attributes of the volume snapshot, by defining it in a YAML manifest file. Follow these steps to create a volume snapshot class for Azure Disks.
Use your favorite text editor to create a YAML manifest file such as code acstor-volumesnapshotclass.yaml
.
Paste in the following code. The volume snapshot class name value can be whatever you want.
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: csi-acstor-vsc
driver: containerstorage.csi.azure.com
deletionPolicy: Delete
parameters:
incremental: "true" # available values: "true", "false" ("true" by default for Azure Public Cloud, and "false" by default for Azure Stack Cloud)
Apply the YAML manifest file to create the volume snapshot class.
kubectl apply -f acstor-volumesnapshotclass.yaml
When creation is complete, you'll see a message like:
volumesnapshotclass.snapshot.storage.k8s.io/csi-acstor-vsc created
You can also run kubectl get volumesnapshotclass
to check that the volume snapshot class has been created. You should see output such as:
NAME DRIVER DELETIONPOLICY AGE
csi-acstor-vsc containerstorage.csi.azure.com Delete 11s
Next, you'll create a snapshot of an existing persistent volume claim and apply the volume snapshot class you created in the previous step.
Use your favorite text editor to create a YAML manifest file such as code acstor-volumesnapshot.yaml
.
Paste in the following code. The volumeSnapshotClassName
should be the name of the volume snapshot class that you created in the previous step. For persistentVolumeClaimName
, use the name of the persistent volume claim that you want to take a snapshot of. The volume snapshot name value can be whatever you want.
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: azuredisk-volume-snapshot
spec:
volumeSnapshotClassName: csi-acstor-vsc
source:
persistentVolumeClaimName: azurediskpvc
Apply the YAML manifest file to create the volume snapshot.
kubectl apply -f acstor-volumesnapshot.yaml
When creation is complete, you'll see a message like:
volumesnapshot.snapshot.storage.k8s.io/azuredisk-volume-snapshot created
You can also run kubectl get volumesnapshot
to check that the volume snapshot has been created. If READYTOUSE
indicates true, you can move on to the next step.
Now you can create a new persistent volume claim that uses the volume snapshot as a data source.
Use your favorite text editor to create a YAML manifest file such as code acstor-pvc-restored.yaml
.
Paste in the following code. The storageClassName
must match the storage class that you used when creating the original persistent volume. For example, if you're using ephemeral disk (local NVMe) instead of Azure Disks for back-end storage, change storageClassName
to acstor-ephemeraldisk
. For the data source name value, use the name of the volume snapshot that you created in the previous step. The metadata name value for the persistent volume claim can be whatever you want.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-azuredisk-snapshot-restored
spec:
accessModes:
- ReadWriteOnce
storageClassName: acstor-azuredisk
resources:
requests:
storage: 100Gi
dataSource:
name: azuredisk-volume-snapshot
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
Apply the YAML manifest file to create the PVC.
kubectl apply -f acstor-pvc-restored.yaml
When creation is complete, you'll see a message like:
persistentvolumeclaim/pvc-azuredisk-snapshot-restored created
You can also run kubectl describe pvc pvc-azuredisk-snapshot-restored
to check that the persistent volume has been created. You should status Pending and the message waiting for first consumer to be created before binding.
Patarimas
If you already created a restored persistent volume claim and want to apply the yaml file again to correct an error or make a change, you'll need to first delete the old persistent volume claim before applying the yaml file again: kubectl delete pvc <pvc-name>
.
Before you create a new pod, you might want to delete the original pod that you created the snapshot from.
kubectl get pods
to list the pods. Make sure you're deleting the right pod.kubectl delete pod <pod-name>
.Next, create a new pod using the restored persistent volume claim. Create the pod using Fio (Flexible I/O Tester) for benchmarking and workload simulation, and specify a mount path for the persistent volume.
Use your favorite text editor to create a YAML manifest file such as code acstor-pod2.yaml
.
Paste in the following code. The persistent volume claim claimName
should be the name of the restored snapshot persistent volume claim that you created. The metadata name value for the pod can be whatever you want.
kind: Pod
apiVersion: v1
metadata:
name: fiopod2
spec:
nodeSelector:
acstor.azure.com/io-engine: acstor
volumes:
- name: diskpv
persistentVolumeClaim:
claimName: pvc-azuredisk-snapshot-restored
containers:
- name: fio
image: nixery.dev/shell/fio
args:
- sleep
- "1000000"
volumeMounts:
- mountPath: "/volume"
name: diskpv
Apply the YAML manifest file to deploy the pod.
kubectl apply -f acstor-pod2.yaml
You should see output similar to the following:
pod/fiopod2 created
Check that the pod is running and that the persistent volume claim has been bound successfully to the pod:
kubectl describe pod fiopod2
kubectl describe pvc pvc-azuredisk-snapshot-restored
Check fio testing to see its current status:
kubectl exec -it fiopod2 -- fio --name=benchtest --size=800m --filename=/volume/test --direct=1 --rw=randrw --ioengine=libaio --bs=4k --iodepth=16 --numjobs=8 --time_based --runtime=60
You've now deployed a new pod from the restored persistent volume claim, and you can use it for your Kubernetes workloads.
Įvykiai
03-31 23 - 04-02 23
Didžiausias "Fabric", Power BI ir SQL mokymosi įvykis. Kovo 31 d. – balandžio 2 d. Naudokite kodą FABINSIDER, kad įrašytumėte $400.
Registruokitės šiandienMokymas
Modulis
Learn storage concepts that help you solve real problems with Windows containers running on Azure Kubernetes Service (AKS) and AKS Hybrid.
Sertifikatas
Microsoft Certified: Azure for SAP Workloads Specialty - Certifications
Demonstrate planning, migration, and operation of an SAP solution on Microsoft Azure while you leverage Azure resources.