-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf0a6be
commit f2e57cc
Showing
17 changed files
with
367 additions
and
0 deletions.
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 PowerVS 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,18 @@ | ||
|
||
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: powervs-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: powervs-sc | ||
provisioner: powervs.csi.ibm.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Dynamic Volume Provisioning | ||
This example shows how to create a PowerVS volume and consume it from container dynamically. | ||
|
||
## Prerequisites | ||
|
||
1. Kubernetes 1.13+ (CSI 1.0). | ||
|
||
2. The [powervs-ebs-csi-driver](https://github.com/ppc64le-cloud/powervs-csi-driver) is installed. | ||
|
||
## Usage | ||
|
||
1. Create a sample app along with the StorageClass and the PersistentVolumeClaim: | ||
``` | ||
kubectl apply -f specs/ | ||
``` | ||
|
||
2. Validate the volume was created and `volumeHandle` contains an PowerVS volumeID: | ||
``` | ||
kubectl describe pv | ||
``` | ||
|
||
3. Validate the pod successfully wrote data to the volume: | ||
``` | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
4. Cleanup resources: | ||
``` | ||
kubectl delete -f specs/ | ||
``` |
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,11 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: powervs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: powervs-sc | ||
resources: | ||
requests: | ||
storage: 4Gi |
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: centos | ||
command: ["/bin/sh"] | ||
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: powervs-claim |
6 changes: 6 additions & 0 deletions
6
examples/kubernetes/dynamic-provisioning/specs/storageclass.yaml
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: powervs-sc | ||
provisioner: powervs.csi.ibm.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## Volume Resizing | ||
This example shows how to resize PowerVS persistence volume using volume resizing features. | ||
|
||
|
||
## Usage | ||
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 | ||
|
||
2. Deploy the example: | ||
```sh | ||
kubectl apply -f specs/ | ||
``` | ||
|
||
3. Verify the volume is created and Pod is running: | ||
```sh | ||
kubectl get pv | ||
kubectl get po app | ||
``` | ||
|
||
4. Expand the volume size by increasing the capacity in PVC's `spec.resources.requests.storage`: | ||
```sh | ||
kubectl edit pvc powervs-claim | ||
``` | ||
Save the result at the end of the edit. | ||
|
||
5. Verify that both the persistence volume and persistence volume claim are resized: | ||
```sh | ||
kubectl get pv | ||
kubectl get pvc | ||
``` | ||
You should see that both should have the new value relfected in the capacity fields. | ||
|
||
6. Verify that the application is continuously running without any interruption: | ||
```sh | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
7. Cleanup resources: | ||
``` | ||
kubectl delete -f specs/ | ||
``` |
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,36 @@ | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1 | ||
metadata: | ||
name: resize-sc | ||
provisioner: powervs.csi.ibm.com | ||
allowVolumeExpansion: true | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: powervs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: resize-sc | ||
resources: | ||
requests: | ||
storage: 4Gi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: app | ||
spec: | ||
containers: | ||
- name: app | ||
image: centos | ||
command: ["/bin/sh"] | ||
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: powervs-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,42 @@ | ||
# Static Provisioning | ||
This example shows how to create and consume persistent volume from exising PowerVS using static provisioning. | ||
|
||
## Usage | ||
1. Edit the PersistentVolume spec in [example manifest](./specs/example.yaml). Update `volumeHandle` with PowerVS volume ID that you are going to use, and update the `fsType` with the filesystem type of the volume. In this example, I have a pre-created PowerVS volume and it is formatted with xfs filesystem. | ||
|
||
``` | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: test-pv | ||
spec: | ||
capacity: | ||
storage: 50Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
csi: | ||
driver: powervs.csi.ibm.com | ||
volumeHandle: {volumeId} | ||
fsType: xfs | ||
``` | ||
|
||
2. Deploy the example: | ||
```sh | ||
kubectl apply -f specs/ | ||
``` | ||
|
||
3. Verify application pod is running: | ||
```sh | ||
kubectl describe po app | ||
``` | ||
|
||
4. Validate the pod successfully wrote data to the volume: | ||
```sh | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
5. Cleanup resources: | ||
```sh | ||
kubectl delete -f specs/ | ||
``` |
46 changes: 46 additions & 0 deletions
46
examples/kubernetes/static-provisioning/specs/example.yaml
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,46 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: test-pv | ||
spec: | ||
capacity: | ||
storage: 50Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: "" | ||
csi: | ||
driver: powervs.csi.ibm.com | ||
volumeHandle: vol-05786ec9ec9526b67 | ||
fsType: xfs | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: powervs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: "" | ||
resources: | ||
requests: | ||
storage: 50Gi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: app | ||
spec: | ||
containers: | ||
- name: app | ||
image: centos | ||
command: ["/bin/sh"] | ||
args: | ||
["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: powervs-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,25 @@ | ||
# Configuring StorageClass | ||
This example shows how to configure Kubernetes storageclass to provision PowerVS volumes with various configuration parameters. PowerVS CSI driver is compatiable with in-tree PowerVS plugin on StorageClass parameters. | ||
|
||
## Usage | ||
1. Edit the StorageClass spec in [example manifest](./specs/example.yaml) and update storageclass parameters to desired value. In this example, a `tier1` PowerVS volume will be created and formatted to `xfs` filesystem. | ||
|
||
2. Deploy the example: | ||
```sh | ||
kubectl apply -f specs/ | ||
``` | ||
|
||
3. Verify the volume is created: | ||
```sh | ||
kubectl describe pv | ||
``` | ||
|
||
4. Validate the pod successfully wrote data to the volume: | ||
```sh | ||
kubectl exec -it app cat /data/out.txt | ||
``` | ||
|
||
5. Cleanup resources: | ||
```sh | ||
kubectl delete -f specs/ | ||
``` |
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 @@ | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1 | ||
metadata: | ||
name: powervs-sc | ||
provisioner: powervs.csi.ibm.com | ||
volumeBindingMode: WaitForFirstConsumer | ||
parameters: | ||
csi.storage.k8s.io/fstype: xfs | ||
type: tier3 | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: powervs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: powervs-sc | ||
resources: | ||
requests: | ||
storage: 4Gi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: app | ||
spec: | ||
containers: | ||
- name: app | ||
image: centos | ||
command: ["/bin/sh"] | ||
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 5; done"] | ||
volumeMounts: | ||
- name: persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: persistent-storage | ||
persistentVolumeClaim: | ||
claimName: powervs-claim |
File renamed without changes.
File renamed without changes.
File renamed without changes.