---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: efs-statefulset-volumeclaimtemplate-app
spec:
  selector:
    matchLabels:
      app: efs-statefulset-volumeclaimtemplate-app
  serviceName: efs-statefulset-volumeclaimtemplate-app
  replicas: 3
  template:
    metadata:
      labels:
        app: efs-statefulset-volumeclaimtemplate-app
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: linux
        image: centos
        command: ["/bin/sh"]
        args: ["-c", "while true; do echo ${POD_NAME}: $(date -u) >> /data/out; sleep 5; done"]
        volumeMounts:
        - name: efs-storage
          mountPath: /data
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
  volumeClaimTemplates:
  - metadata:
      name: efs-storage
      labels:
        app: efs-statefulset-volumeclaimtemplate-app
    spec:
      accessModes: [ "ReadWriteMany" ]
      storageClassName: "efs"
      resources:
        requests:
          storage: 5Gi