Skip to content

Commit 25772d4

Browse files
author
Power Cloud Robot
authored
Merge pull request #53 from Madhan-SWE/example_workloads
examples added
2 parents ceef595 + dc2b171 commit 25772d4

File tree

15 files changed

+351
-19
lines changed

15 files changed

+351
-19
lines changed

example/pod.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Raw Block Volume
2+
This example shows how to consume a dynamically-provisioned PowerVS volume as a raw block device.
3+
4+
### Edit [Persistence Volume Claim Spec](./specs/raw-claim.yaml)
5+
Make sure the `volumeMode` is `Block`.
6+
7+
### Edit [Application Pod](./specs/pod.yaml)
8+
Make sure the pod is consuming the PVC with the defined name and `volumeDevices` is used instead of `volumeMounts`.
9+
10+
### Deploy the Application
11+
```sh
12+
kubectl apply -f examples/kubernetes/block-volume/specs/storageclass.yaml
13+
kubectl apply -f examples/kubernetes/block-volume/specs/raw-claim.yaml
14+
kubectl apply -f examples/kubernetes/block-volume/specs/pod.yaml
15+
```
16+
17+
### Access Block Device
18+
After the objects are created, verify that pod is running:
19+
20+
```sh
21+
$ kubectl get pods
22+
NAME READY STATUS RESTARTS AGE
23+
app 1/1 Running 0 16m
24+
```
25+
Verify the device node is mounted inside the container:
26+
27+
```sh
28+
$ kubectl exec -ti app -- ls -al /dev/xvda
29+
brw-rw---- 1 root disk 202, 23296 Mar 12 04:23 /dev/xvda
30+
```
31+
32+
Write to the device using:
33+
34+
```sh
35+
dd if=/dev/zero of=/dev/xvda bs=1024k count=100
36+
100+0 records in
37+
100+0 records out
38+
104857600 bytes (105 MB, 100 MiB) copied, 0.0492386 s, 2.1 GB/s
39+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
apiVersion: v1
3+
kind: Pod
4+
metadata:
5+
name: app
6+
spec:
7+
containers:
8+
- name: app
9+
image: busybox
10+
command: ["/bin/sh", "-c"]
11+
args: ["tail -f /dev/null"]
12+
volumeDevices:
13+
- name: data
14+
devicePath: /dev/xvda
15+
volumes:
16+
- name: data
17+
persistentVolumeClaim:
18+
claimName: block-claim
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: block-claim
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
volumeMode: Block
9+
storageClassName: powervs-sc
10+
resources:
11+
requests:
12+
storage: 10Gi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Dynamic Volume Provisioning
2+
This example shows how to create a PowerVS volume and consume it from container dynamically.
3+
4+
## Prerequisites
5+
6+
1. Kubernetes 1.13+ (CSI 1.0).
7+
8+
2. The [powervs-ebs-csi-driver](https://github.com/ppc64le-cloud/powervs-csi-driver) is installed.
9+
10+
## Usage
11+
12+
1. Create a sample app along with the StorageClass and the PersistentVolumeClaim:
13+
```
14+
kubectl apply -f specs/
15+
```
16+
17+
2. Validate the volume was created and `volumeHandle` contains an PowerVS volumeID:
18+
```
19+
kubectl describe pv
20+
```
21+
22+
3. Validate the pod successfully wrote data to the volume:
23+
```
24+
kubectl exec -it app cat /data/out.txt
25+
```
26+
27+
4. Cleanup resources:
28+
```
29+
kubectl delete -f specs/
30+
```

example/pvc.yaml renamed to examples/kubernetes/dynamic-provisioning/specs/claim.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ spec:
88
storageClassName: powervs-sc
99
resources:
1010
requests:
11-
storage: 1Gi
11+
storage: 4Gi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: app
5+
spec:
6+
containers:
7+
- name: app
8+
image: centos
9+
command: ["/bin/sh"]
10+
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"]
11+
volumeMounts:
12+
- name: persistent-storage
13+
mountPath: /data
14+
volumes:
15+
- name: persistent-storage
16+
persistentVolumeClaim:
17+
claimName: powervs-claim
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: StorageClass
2+
apiVersion: storage.k8s.io/v1
3+
metadata:
4+
name: powervs-sc
5+
provisioner: powervs.csi.ibm.com
6+
volumeBindingMode: WaitForFirstConsumer
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Volume Resizing
2+
This example shows how to resize PowerVS persistence volume using volume resizing features.
3+
4+
5+
## Usage
6+
1. Add `allowVolumeExpansion: true` in the StorageClass spec in [example manifest](./spec/example.yaml) to enable volume expansion. You can only expand a PVC if its storage class’s allowVolumeExpansion field is set to true
7+
8+
2. Deploy the example:
9+
```sh
10+
kubectl apply -f specs/
11+
```
12+
13+
3. Verify the volume is created and Pod is running:
14+
```sh
15+
kubectl get pv
16+
kubectl get po app
17+
```
18+
19+
4. Expand the volume size by increasing the capacity in PVC's `spec.resources.requests.storage`:
20+
```sh
21+
kubectl edit pvc powervs-claim
22+
```
23+
Save the result at the end of the edit.
24+
25+
5. Verify that both the persistence volume and persistence volume claim are resized:
26+
```sh
27+
kubectl get pv
28+
kubectl get pvc
29+
```
30+
You should see that both should have the new value relfected in the capacity fields.
31+
32+
6. Verify that the application is continuously running without any interruption:
33+
```sh
34+
kubectl exec -it app cat /data/out.txt
35+
```
36+
37+
7. Cleanup resources:
38+
```
39+
kubectl delete -f specs/
40+
```

0 commit comments

Comments
 (0)