如何在 EKS 上使用 storage class 中的卷 gp3?

How to use volume gp3 in storage class on EKS?

我正在为 EKS 将卷 gp2 转换为卷 gp3,但出现此错误。
无法使用存储类“gp3”配置卷:无效的 AWS VolumeType“gp3”
这是我的配置。

存储类

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
  name: gp3
parameters:
  fsType: ext4
  type: gp3
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Retain
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer   

PVC

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: test-pvc
  name: test-pvc
  namespace: default
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: gp3   

当我输入 kubectl describe pvc/test 时。这是回复:

Name:          test-pvc
Namespace:     default
StorageClass:  gp3
Status:        Pending
Volume:        
Labels:        app=test-pvc
Annotations:   volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/aws-ebs
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
VolumeMode:    Filesystem
Used By:       <none>
Events:
  Type     Reason              Age                  From                         Message
  ----     ------              ----                 ----                         -------
  Warning  ProvisioningFailed  58s (x9 over 4m35s)  persistentvolume-controller  Failed to provision volume with StorageClass "gp3": invalid AWS VolumeType "gp3"   

我使用的是 Kubernetes 1.18 版。
有人能帮我吗。谢谢!

默认的k8s存储驱动只支持gp2。要使用 gp3,您需要安装 AWS EBS CSI 驱动程序。这里官方instruction安装驱动

感谢@gohm'c,但我想添加一个注释,需要在安装 AWS EBS CSI 驱动程序后创建存储 class“ebs-sc”,示例:

cat << EOF | kubectl apply -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ebs-sc
provisioner: ebs.csi.aws.com
parameters:
  type: gp3
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
EOF

参考文献: