Skip to content

Commit

Permalink
Add example for multiple pods (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheng Pan authored Feb 11, 2019
1 parent 9ce12f8 commit 75acc93
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Before the example, you need to:
#### Example links
* [Static provisioning](../examples/kubernetes/static_provisioning/README.md)
* [Dynamic provisioning](../examples/kubernetes/dynamic_provisioning/README.md)
* Accessing the filesystem from multiple pods
* [Accessing the filesystem from multiple pods](../examples/kubernetes/multiple_pods/README.md)

## Development
Please go through [CSI Spec](https://github.com/container-storage-interface/spec/blob/master/spec.md) and [General CSI driver development guideline](https://kubernetes-csi.github.io/docs/Development.html) to get some basic understanding of CSI driver before you start.
Expand Down
57 changes: 57 additions & 0 deletions examples/kubernetes/multiple_pods/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Multiple Pods Read Write Many
This example shows how to create a static provisioned FSx for Lustre PV and access it from multiple pods with RWX access mode.

### Edit Persistent Volume
Edit persistent volume using sample [spec](pv.yaml):
```
apiVersion: v1
kind: PersistentVolume
metadata:
name: fsx-pv
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
storageClassName: fsx-sc
csi:
driver: fsx.csi.aws.com
volumeHandle: [FileSystemId]
volumeAttributes:
dnsname: [DNSName]
```
Replace `volumeHandle` with `FileSystemId` and `dnsname` with `DNSName`. Note that the access mode is `RWX` which means the PV can be read and write from multiple pods.

You can get both `FileSystemId` and `DNSName` using AWS CLI:

```
aws fsx describe-file-systems
```

### Deploy the Application
Create PV, persistence volume claim (PVC), storageclass and the pods that consume the PV:
```
kubectl apply -f examples/kubernetes/static_provisioning/storageclass.yaml
kubectl apply -f examples/kubernetes/static_provisioning/pv.yaml
kubectl apply -f examples/kubernetes/static_provisioning/claim.yaml
kubectl apply -f examples/kubernetes/static_provisioning/pod1.yaml
kubectl apply -f examples/kubernetes/static_provisioning/pod2.yaml
```

Both pod1 and pod2 are writing to the same FSx for Lustre filesystem at the same time.

### Check the Application uses FSx for Lustre filesystem
After the objects are created, verify that pod is running:

```
kubectl get pods
```

Also verify that data is written onto FSx for Luster filesystem:

```
kubectl exec -ti app1 -- tail -f /data/out1.txt
kubectl exec -ti app2 -- tail -f /data/out2.txt
```
4 changes: 2 additions & 2 deletions examples/kubernetes/multiple_pods/pv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ spec:
storageClassName: fsx-sc
csi:
driver: fsx.csi.aws.com
volumeHandle: fs-0b88f4c7b6f8772d7
volumeHandle: fs-0199e5a63bd90f796
volumeAttributes:
dnsname: fs-0b88f4c7b6f8772d7.fsx.us-west-2.amazonaws.com
dnsname: fs-0199e5a63bd90f796.fsx.us-east-1.amazonaws.com

0 comments on commit 75acc93

Please sign in to comment.