Kubernetes:块持久卷中 "storage" 字段的意义是什么?

Kubernetes: What is the significance of "storage" field in a block Persistent Volume?

场景

我有一个 volumeModeBlock 的 PersistentVolume。它被定义为:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: block-vol
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 1Gi
  local:
    path: /dev/sdb # this path on the host specified below is used as a device mount
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - <my-host>
  persistentVolumeReclaimPolicy: Retain
  storageClassName: block-storage
  volumeMode: Block

当我用 VolumeClaimTemplatestatefulset 上安装它时,我将它的 storage 字段指定为 1Gi。但是,当执行到已部署的 pod 时,我看到块大小超过 1Gi(这是该设备在物理机上的实际大小)

StatefulSet YAML:


apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "nginx"
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: k8s.gcr.io/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
        volumeDevices:
        - name: rawdev0
          devicePath: /dev/kdb0
  volumeClaimTemplates:
  - metadata:
      name: rawdev0
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: block-storage
      volumeMode: Block
      resources:
        requests:
          storage: 1Gi

我已经使用 blockdev 找到块的大小(以字节为单位):

root@nginx-0:/# ls -lhrt /dev/kdb0 
brw-rw----. 1 root disk 8, 16 Jan 13 19:49 /dev/kdb0

root@nginx-0:/# blockdev --getsize64 /dev/kdb0 
536870912000 #size of block in bytes

问题

在这种情况下,storage 字段表示什么?

Kubernetes 对 local volumes 的存储大小无能为力。创建 PersistentVolume 的管理员必须设置适当的大小,以便进行粒度调整 he/she 可能应该创建自己的分区,而不是将本地卷映射到目录。

PersistentVolumeClaim 中的存储大小是一个请求,以便应用程序至少获得该大小的卷。