Skip to content

Commit d9ed510

Browse files
committed
Learn Editor: Update use-container-storage-with-local-disk.md
1 parent 578ac10 commit d9ed510

File tree

1 file changed

+119
-70
lines changed

1 file changed

+119
-70
lines changed

articles/storage/container-storage/use-container-storage-with-local-disk.md

Lines changed: 119 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.custom: references_regions
1414
[Azure Container Storage](container-storage-introduction.md) is a cloud-based volume management, deployment, and orchestration service built natively for containers. This article shows you how to configure Azure Container Storage to use Ephemeral Disk as back-end storage for your Kubernetes workloads. At the end, you'll have a pod that's using either local NVMe or temp SSD as its storage.
1515

1616
> [!IMPORTANT]
17-
> Local disks are ephemeral, meaning that they're created on the local virtual machine (VM) storage and not saved to an Azure storage service. Data will be lost on these disks if you stop/deallocate your VM.
17+
> Local disks are ephemeral, meaning that they're created on the local virtual machine (VM) storage and not saved to an Azure storage service. Data will be lost on these disks if you stop/deallocate your VM. You can only create [Kubernetes generic ephemeral volumes](https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/#generic-ephemeral-volumes) from an Ephemeral Disk storage pool. If you want to create a persistent volume, you have to enable [replication for your storage pool](#optional-create-storage-pool-with-volume-replication-nvme-only).
1818
1919
## Prerequisites
2020

@@ -129,78 +129,14 @@ Run `kubectl get sc` to display the available storage classes. You should see a
129129
> [!IMPORTANT]
130130
> Don't use the storage class that's marked **internal**. It's an internal storage class that's needed for Azure Container Storage to work.
131131
132-
## Create a persistent volume claim
133-
134-
A persistent volume claim (PVC) is used to automatically provision storage based on a storage class. Follow these steps to create a PVC using the new storage class.
132+
## Deploy a pod with a generic ephemeral volume
135133

136-
1. Use your favorite text editor to create a YAML manifest file such as `code acstor-pvc.yaml`.
137-
138-
1. Paste in the following code and save the file. The PVC `name` value can be whatever you want.
139-
140-
```yml
141-
apiVersion: v1
142-
kind: PersistentVolumeClaim
143-
metadata:
144-
name: ephemeralpvc
145-
spec:
146-
accessModes:
147-
- ReadWriteOnce
148-
storageClassName: acstor-ephemeraldisk # replace with the name of your storage class if different
149-
resources:
150-
requests:
151-
storage: 100Gi
152-
```
153-
154-
1. Apply the YAML manifest file to create the PVC.
155-
156-
```azurecli-interactive
157-
kubectl apply -f acstor-pvc.yaml
158-
```
159-
160-
You should see output similar to:
161-
162-
```output
163-
persistentvolumeclaim/ephemeralpvc created
164-
```
165-
166-
You can verify the status of the PVC by running the following command:
167-
168-
```azurecli-interactive
169-
kubectl describe pvc ephemeralpvc
170-
```
171-
172-
Once the PVC is created, it's ready for use by a pod.
173-
174-
## Deploy a pod and attach a persistent volume
175-
176-
Create a pod using [Fio](https://github.com/axboe/fio) (Flexible I/O Tester) for benchmarking and workload simulation, and specify a mount path for the persistent volume. For **claimName**, use the **name** value that you used when creating the persistent volume claim.
134+
Create a pod using [Fio](https://github.com/axboe/fio) (Flexible I/O Tester) for benchmarking and workload simulation, that uses a generic ephemeral volume.
177135

178136
1. Use your favorite text editor to create a YAML manifest file such as `code acstor-pod.yaml`.
179137

180138
1. Paste in the following code and save the file.
181139

182-
```yml
183-
kind: Pod
184-
apiVersion: v1
185-
metadata:
186-
name: fiopod
187-
spec:
188-
nodeSelector:
189-
acstor.azure.com/io-engine: acstor
190-
volumes:
191-
- name: ephemeralpv
192-
persistentVolumeClaim:
193-
claimName: ephemeralpvc
194-
containers:
195-
- name: fio
196-
image: nixery.dev/shell/fio
197-
args:
198-
- sleep
199-
- "1000000"
200-
volumeMounts:
201-
- mountPath: "/volume"
202-
name: ephemeralpv
203-
```
204140

205141
1. Apply the YAML manifest file to deploy the pod.
206142

@@ -214,11 +150,11 @@ Create a pod using [Fio](https://github.com/axboe/fio) (Flexible I/O Tester) for
214150
pod/fiopod created
215151
```
216152

217-
1. Check that the pod is running and that the persistent volume claim has been bound successfully to the pod:
153+
1. Check that the pod is running and that the ephemeral volume claim has been bound successfully to the pod:
218154

219155
```azurecli-interactive
220156
kubectl describe pod fiopod
221-
kubectl describe pvc ephemeralpvc
157+
kubectl describe pvc fiopod-ephemeralvolume
222158
```
223159

224160
1. Check fio testing to see its current status:
@@ -275,6 +211,7 @@ Follow these steps to create a storage pool using local NVMe with replication.
275211

276212
1. Use your favorite text editor to create a YAML manifest file such as `code acstor-storagepool.yaml`.
277213

214+
278215
1. Paste in the following code and save the file. The storage pool **name** value can be whatever you want. Set replicas to 3 or 5.
279216

280217
```yml
@@ -308,7 +245,119 @@ Follow these steps to create a storage pool using local NVMe with replication.
308245
kubectl describe sp <storage-pool-name> -n acstor
309246
```
310247

311-
When the storage pool is created, Azure Container Storage will create a storage class on your behalf, using the naming convention `acstor-<storage-pool-name>`. Now you can [display the available storage classes](#display-the-available-storage-classes) and [create a persistent volume claim](#create-a-persistent-volume-claim).
248+
When the storage pool is created, Azure Container Storage will create a storage class on your behalf, using the naming convention `acstor-<storage-pool-name>`. Now you can [display the available storage classes](#display-the-available-storage-classes) and create a persistent volume claim.
249+
250+
## Create a persistent volume claim
251+
252+
A persistent volume claim (PVC) is used to automatically provision storage based on a storage class. Follow these steps to create a PVC using the new storage class.
253+
254+
1. Use your favorite text editor to create a YAML manifest file such as `code acstor-pvc.yaml`.
255+
256+
1. Paste in the following code and save the file. The PVC `name` value can be whatever you want.
257+
258+
```yml
259+
apiVersion: v1
260+
kind: PersistentVolumeClaim
261+
metadata:
262+
name: ephemeralpvc
263+
spec:
264+
accessModes:
265+
- ReadWriteOnce
266+
storageClassName: acstor-ephemeraldisk-nvme # replace with the name of your storage class if different
267+
resources:
268+
requests:
269+
storage: 100Gi
270+
```
271+
272+
1. Apply the YAML manifest file to create the PVC.
273+
274+
```azurecli-interactive
275+
kubectl apply -f acstor-pvc.yaml
276+
```
277+
278+
You should see output similar to:
279+
280+
```output
281+
persistentvolumeclaim/ephemeralpvc created
282+
```
283+
284+
You can verify the status of the PVC by running the following command:
285+
286+
```azurecli-interactive
287+
kubectl describe pvc ephemeralpvc
288+
```
289+
290+
Once the PVC is created, it's ready for use by a pod.
291+
292+
## Deploy a pod and attach a persistent volume
293+
294+
Create a pod using [Fio](https://github.com/axboe/fio) (Flexible I/O Tester) for benchmarking and workload simulation, and specify a mount path for the persistent volume. For **claimName**, use the **name** value that you used when creating the persistent volume claim.
295+
296+
1. Use your favorite text editor to create a YAML manifest file such as `code acstor-pod.yaml`.
297+
298+
1. Paste in the following code and save the file.
299+
300+
```yml
301+
kind: Pod
302+
apiVersion: v1
303+
metadata:
304+
name: fiopod
305+
spec:
306+
nodeSelector:
307+
acstor.azure.com/io-engine: acstor
308+
volumes:
309+
- name: ephemeralpv
310+
persistentVolumeClaim:
311+
claimName: ephemeralpvc
312+
containers:
313+
- name: fio
314+
image: nixery.dev/shell/fio
315+
args:
316+
- sleep
317+
- "1000000"
318+
volumeMounts:
319+
- mountPath: "/volume"
320+
name: ephemeralpv
321+
```
322+
323+
1. Apply the YAML manifest file to deploy the pod.
324+
325+
```azurecli-interactive
326+
kubectl apply -f acstor-pod.yaml
327+
```
328+
329+
You should see output similar to the following:
330+
331+
```output
332+
pod/fiopod created
333+
```
334+
335+
1. Check that the pod is running and that the persistent volume claim has been bound successfully to the pod:
336+
337+
```azurecli-interactive
338+
kubectl describe pod fiopod
339+
kubectl describe pvc ephemeralpvc
340+
```
341+
342+
1. Check fio testing to see its current status:
343+
344+
```azurecli-interactive
345+
kubectl exec -it fiopod -- fio --name=benchtest --size=800m --filename=/volume/test --direct=1 --rw=randrw --ioengine=libaio --bs=4k --iodepth=16 --numjobs=8 --time_based --runtime=60
346+
```
347+
348+
You've now deployed a pod that's using Ephemeral Disk as its storage, and you can use it for your Kubernetes workloads.
349+
350+
## Detach and reattach a persistent volume
351+
352+
To detach a persistent volume, delete the pod that the persistent volume is attached to. Replace `<pod-name>` with the name of the pod, for example **fiopod**.
353+
354+
```azurecli-interactive
355+
kubectl delete pods <pod-name>
356+
```
357+
358+
To reattach a persistent volume, simply reference the persistent volume claim name in the YAML manifest file as described in [Deploy a pod and attach a persistent volume](#deploy-a-pod-and-attach-a-persistent-volume).
359+
360+
To check which persistent volume a persistent volume claim is bound to, run `kubectl get pvc <persistent-volume-claim-name>`.
312361

313362
## See also
314363

0 commit comments

Comments
 (0)