Kubernetes 持久卷小于请求

Kubernetes persistent volumes smaller than requested

尝试使用 MongoDB Kubernetes Operator 将 MongoDB 部署到 Kubernetes 集群时,我在持久卷中看到以下错误:

$ kubectl describe pvc data-volume-mongodb-0
(...)
  Warning  ProvisioningFailed    31s (x4 over 2m45s)   (...).com_csi-controller-0_b0e3662f-4b9e-4de5-a45b-0132ab5971a8  failed to provision volume with StorageClass "tier1": created volume capacity 9663676416 less than requested capacity 10000000000.(...)

这是我的提供商的问题还是已知的 Kubernetes 问题?

MongoDB Kubernetes Operator 默认数据卷容量为 10G.

我可以用我自己的 PVC 覆盖它:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: data-volume-kompas2mongo-0
  labels:
    app: kompas2mongo-svc
spec:
  storageClassName: tier1
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

部署到我的集群:

$ kubectl apply -f mongodb-data-pvc.yaml

我对日志卷做了同样的事情:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: logs-volume-kompas2mongo-0
  labels:
    app: kompas2mongo-svc
spec:
  storageClassName: tier1
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi

部署到我的集群:

$ kubectl apply -f mongodb-logs-pvc.yaml

10G 更改为 10Gi,将 2G 更改为 2Gi 对我有用。之后,两个卷都得到了正确配置:

$ kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                STORAGECLASS   REASON   AGE
pvc-df6b01e9-af96-470d-af37-49c6993b70e6   10Gi       RWO            Delete           Bound    default/data-volume-kompas2mongo-0   tier1                   3h8m
pvc-f2f08105-61c4-444c-b7e0-900aa403c122   2Gi        RWO            Delete           Bound    default/logs-volume-kompas2mongo-0   tier1                   3h8m