-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs by passing fstype correctly:
1. Fix fstype parameter prefix 2. Remove fstype in storageclass in favor of csi.storage.k8s.io/fstype 3. Update e2e test 4. Add static provisioning example 5. Update run-e2e-test script to build driver before create cluster
- Loading branch information
Cheng Pan
committed
Aug 14, 2019
1 parent
3bdb76d
commit 1848e8b
Showing
11 changed files
with
289 additions
and
146 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,52 @@ | ||
# Static Provisioning | ||
This example shows how to create and consume persistence volume from exising EBS using static provisioning. | ||
|
||
## Usage | ||
1. Edit the PersistentVolume spec in [example manifest](./specs/example.yaml). Update `volumeHandle` with EBS 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 EBS volume in us-east-1c availability zone and it is formatted with xfs filesystem. | ||
|
||
``` | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: test-pv | ||
spec: | ||
capacity: | ||
storage: 50Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: ebs-sc | ||
csi: | ||
driver: ebs.csi.aws.com | ||
volumeHandle: {volumeId} | ||
fsType: xfs | ||
nodeAffinity: | ||
required: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: topology.ebs.csi.aws.com/zone | ||
operator: In | ||
values: | ||
- us-east-1c | ||
``` | ||
Note that node affinity is used here since EBS volume is created in us-east-1c, hence only node in the same AZ can consume this persisence volume. | ||
|
||
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/ | ||
``` |
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
kind: StorageClass | ||
apiVersion: storage.k8s.io/v1 | ||
metadata: | ||
name: ebs-sc | ||
provisioner: ebs.csi.aws.com | ||
volumeBindingMode: WaitForFirstConsumer | ||
reclaimPolicy: Retain | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolume | ||
metadata: | ||
name: test-pv | ||
spec: | ||
capacity: | ||
storage: 50Gi | ||
volumeMode: Filesystem | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: ebs-sc | ||
csi: | ||
driver: ebs.csi.aws.com | ||
volumeHandle: vol-05786ec9ec9526b67 | ||
fsType: xfs | ||
nodeAffinity: | ||
required: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: topology.ebs.csi.aws.com/zone | ||
operator: In | ||
values: | ||
- us-east-1c | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: ebs-claim | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
storageClassName: ebs-sc | ||
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: ebs-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
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
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
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
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
Oops, something went wrong.