在Amazon Elastic Kubernetes Service (EKS)上實現使用Elastic Block Store (EBS)的StorageClass
step 1
安裝Amazon EBS CSI驅動器:
kubectl apply -k "github.com/kubernetes-sigs/aws-ebs-csi-driver/deploy/kubernetes/overlays/stable/ecr/?ref=release-1.3"
step 2
建立StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-sc
provisioner: ebs.csi.aws.com
step3
建立PersistentVolumeClaim (PVC)
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ebs-pvc
spec:
storageClassName: ebs-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
step 4
建立Pod:
apiVersion: v1
kind: Pod
metadata:
name: ebs-pod
spec:
containers:
- name: my-container
image: nginx
volumeMounts:
- mountPath: "/mnt/data"
name: ebs-volume
volumes:
- name: ebs-volume
persistentVolumeClaim:
claimName: ebs-pvc