Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example stateful sets #43

Merged
merged 1 commit into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Before the example, you need to:
* [Static provisioning](../examples/kubernetes/static_provisioning/README.md)
* [Encryption in transit](../examples/kubernetes/encryption_in_transit/README.md)
* [Accessing the filesystem from multiple pods](../examples/kubernetes/multiple_pods/README.md)
* [Consume EFS in StatefulSets](../examples/kubernetes/statefulset/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
41 changes: 41 additions & 0 deletions examples/kubernetes/statefulset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Use in Stateful Set
This example shows how to consume EFS filesystem from StatefulSets using the driver. Before the example, refer to [StatefulSets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/) for what it is.

## Deploy the example

```sh
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-efs-csi-driver/master/examples/kubernetes/statefulset/specs/example.yaml
```

## Check the StatefulSets Application
Check StatefulSets is deployed successfully:
```sh
$ kubectl get sts
NAME READY AGE
efs-app-sts 3/3 70m
```

Check the pods are running:
```sh
$ kubectl get po
NAME READY STATUS RESTARTS AGE
efs-app-sts-0 1/1 Running 0 71m
efs-app-sts-1 1/1 Running 0 71m
efs-app-sts-2 1/1 Running 0 71m
```

Check data are written onto EFS filesystem:
```sh
$ kubectl exec -ti efs-app-sts-0 -- tail -f /efs-data/out.txt
Mon May 6 00:50:15 UTC 2019
Mon May 6 00:50:18 UTC 2019
Mon May 6 00:50:19 UTC 2019
Mon May 6 00:50:20 UTC 2019
Mon May 6 00:50:23 UTC 2019
Mon May 6 00:50:24 UTC 2019
Mon May 6 00:50:25 UTC 2019
Mon May 6 00:50:28 UTC 2019
Mon May 6 00:50:29 UTC 2019
Mon May 6 00:50:30 UTC 2019
```

56 changes: 56 additions & 0 deletions examples/kubernetes/statefulset/specs/example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: efs-pv
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: efs-sc
csi:
driver: efs.csi.aws.com
volumeHandle: fs-4af69aab
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: efs-claim
spec:
accessModes:
- ReadWriteMany
storageClassName: efs-sc
resources:
requests:
storage: 5Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: efs-app-sts
spec:
selector:
matchLabels:
app: test-efs
serviceName: efs-app
replicas: 3
template:
metadata:
labels:
app: test-efs
spec:
terminationGracePeriodSeconds: 10
containers:
- name: linux
image: amazonlinux:2
command: ["/bin/sh"]
args: ["-c", "while true; do echo $(date -u) >> /efs-data/out.txt; sleep 5; done"]
volumeMounts:
- name: efs-storage
mountPath: /efs-data
volumes:
- name: efs-storage
persistentVolumeClaim:
claimName: efs-claim