k8s无法将vsphere vsan磁盘挂载到pod

时间:2018-04-12 08:23:35

标签: storage vmware vsphere kubernetes

我遇到持久卷和vmware vsan

的问题

我在使用kubespray部署的CentOS 7上使用kubernetes v1.9.5(cloudprovider:vsphere)。 pod无法安装到vsan设备:

Events:
  Type     Reason                 Age   From                       Message
  ----     ------                 ----  ----                       -------
  Normal   Scheduled              2m    default-scheduler          Successfully assigned pvpod to k8s-worker-5
  Normal   SuccessfulMountVolume  2m    kubelet, k8s-worker-5  MountVolume.SetUp succeeded for volume "default-token-c5mqh"
  Warning  FailedMount            56s   kubelet, k8s-worker-5  Unable to mount volumes for pod "pvpod_default(62b1704e-3e27-11e8-9cfc-0050568f0ce4)": timeout expired waiting for volumes to attach/mount for pod "default"/"pvpod". list of unattached/unmounted volumes=[test-volume]

将卷分配给kubernetes worker-5(sdb)

[root@k8s-worker-5 ~]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000ac2d7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     3147775      524288   82  Linux swap / Solaris
/dev/sda3         3147776   209712509   103282367   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
创建了pv和pvc:

[root@k8s-jump ]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM     POLICY   STATUS    CLAIM              STORAGECLASS   REASON    AGE
pvc-60b0f1d9-3e27-11e8-9cfc-0050568f0ce4   2Gi        RWO            Delete               Bound     default/pvcsc001   vsan                     5m

[root@k8s-jump ]# kubectl get pvc
NAME       STATUS    VOLUME                                     CAPACITY       ACCESS MODES   STORAGECLASS   AGE
pvcsc001   Bound     pvc-60b0f1d9-3e27-11e8-9cfc-0050568f0ce4   2Gi            RWO            vsan           5m

这是我的测试部署清单

---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: vsan
provisioner: kubernetes.io/vsphere-volume
parameters:
  datastore: vsanDatastore
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: pvcsc001
      annotations:
    volume.beta.kubernetes.io/storage-class: vsan
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: pvpod
spec:
  containers:
  - name: test-container
    image: k8s.gcr.io/test-webserver
    volumeMounts:
    - name: test-volume
      mountPath: /test-vmdk
  volumes:
  - name: test-volume
    persistentVolumeClaim:
      claimName: pvcsc001

1 个答案:

答案 0 :(得分:0)