Create pv/pvc efs-server-volume
kind: PersistentVolume
apiVersion: v1
metadata:
name: efs-server-volume
spec:
capacity:
storage: 100G
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: efs
csi:
driver: efs.csi.aws.com
volumeHandle: fs-id
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: efs-server-volume
spec:
accessModes:
- ReadWriteMany
storageClassName: efs
resources:
requests:
storage: 100G
Create pod handle
apiVersion: v1
kind: Pod
metadata:
name: efs-server-pod
labels:
name: efs-server-pod
spec:
volumes:
- name: efs-server-volume-data
persistentVolumeClaim:
claimName: efs-server-volume
containers:
- name: efs-server-pod
image: nginx
volumeMounts:
- name: efs-server-volume-data
mountPath: /data
Create folder for EFS
kubectl exec -it efs-server-pod -- bash -c "mkdir /data/<folder-need-create>; chmod 777 /data/<folder-need-create>"
Create PV/VPC that mount volume EFS with folder
kind: PersistentVolume
apiVersion: v1
metadata:
name: nginx-test-pv
spec:
capacity:
storage: 5G
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: efs
csi:
driver: efs.csi.aws.com
volumeHandle: fs-id:/folder-created
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nginx-test-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: efs
resources:
requests:
storage: 5G
Create deployment that mount volume EFS with folder by PV – PVC created above
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-test
labels:
name: nginx-test
spec:
replicas: 2
selector:
matchLabels:
app: nginx-test
template:
metadata:
labels:
app: nginx-test
spec:
volumes:
- name: nginx-share
persistentVolumeClaim:
claimName: nginx-test-pvc
containers:
- name: nginx-test
image: nginx
ports:
- name: nginx-test
containerPort: 80
volumeMounts:
- name: nginx-share
mountPath: /usr/share/nginx/html
Example create MinIO
kind: PersistentVolume
apiVersion: v1
metadata:
name: minio-pv
spec:
capacity:
storage: 100G
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: efs
csi:
driver: efs.csi.aws.com
volumeHandle: fs-id:/minio
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: minio-pvc
spec:
accessModes:
- ReadWriteMany
storageClassName: efs
resources:
requests:
storage: 100G
apiVersion: v1
kind: Pod
metadata:
labels:
app: minio-server
name: minio-server
spec:
containers:
- name: minio-server
image: quay.io/minio/minio
command:
- /bin/bash
- -c
args:
- minio server /data --console-address :9001
volumeMounts:
- mountPath: /data
name: minio-server-data
env:
- name: MINIO_BROWSER_LOGIN_ANIMATION
value: "off"
volumes:
- name: minio-server-data
persistentVolumeClaim:
claimName: minio-pvc