-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from leakingtapan/readme
Add example for block volume
- Loading branch information
Showing
5 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## Raw Block Volume | ||
This example shows how to consume a dynamically-provisioned EBS volume as a raw block device. | ||
|
||
### Edit [Persistence Volume Claim Spec](./specs/raw-claim.yaml) | ||
Make sure the `volumeMode` is `Block`. | ||
|
||
### Edit [Application Pod](./specs/pod.yaml) | ||
Make sure the pod is consuming the PVC with the defined name and `volumeDevices` is used instead of `volumeMounts`. | ||
|
||
### Deploy the Application | ||
```sh | ||
kubectl apply -f examples/kubernetes/block-volume/specs/storageclass.yaml | ||
kubectl apply -f examples/kubernetes/block-volume/specs/raw-claim.yaml | ||
kubectl apply -f examples/kubernetes/block-volume/specs/pod.yaml | ||
``` | ||
|
||
### Access Block Device | ||
After the objects are created, verify that pod is running: | ||
|
||
```sh | ||
$ kubectl get pods | ||
NAME READY STATUS RESTARTS AGE | ||
app 1/1 Running 0 16m | ||
``` | ||
Verify the device node is mounted inside the container: | ||
|
||
```sh | ||
$ kubectl exec -ti app -- ls -al /dev/xvda | ||
brw-rw---- 1 root disk 202, 23296 Mar 12 04:23 /dev/xvda | ||
``` | ||
|
||
Write to the device using: | ||
|
||
```sh | ||
dd if=/dev/zero of=/dev/xvda bs=1024k count=100 | ||
100+0 records in | ||
100+0 records out | ||
104857600 bytes (105 MB, 100 MiB) copied, 0.0492386 s, 2.1 GB/s | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: app | ||
spec: | ||
containers: | ||
- name: app | ||
image: busybox | ||
command: ["/bin/sh", "-c"] | ||
args: ["tail -f /dev/null"] | ||
volumeDevices: | ||
- name: data | ||
devicePath: /dev/xvda | ||
volumes: | ||
- name: data | ||
persistentVolumeClaim: | ||
claimName: block-claim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: block-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Block | ||
storageClassName: ebs-sc | ||
resources: | ||
requests: | ||
storage: 10Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1 | ||
metadata: | ||
name: ebs-sc | ||
provisioner: ebs.csi.aws.com | ||
volumeBindingMode: WaitForFirstConsumer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ kubectl exec -it app cat /data/out.txt | |
4. Cleanup resources: | ||
``` | ||
kubectl delete -f specs/ | ||
``` | ||
``` |