创建带Cinder PV的pod时出现pod has unbound immediate PersistentVolumeClaims

1、环境介绍

K8S+openstack-cloud-controller-manager对接OpenStack Cinder 为K8S提供PV后端
storageclass已经创建好

# kubectl get sc
NAME       PROVISIONER            RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
standard   kubernetes.io/cinder   Delete          Immediate           false                  2d

使用chart部署pod,chart基本文件列表

# tree sc
sc
├── Chart.yaml
├── templates
│   ├── 1g-pv-1.yaml
│   ├── sc-configmap.yaml
│   └── sc.yaml
└── values.yaml

2、POD yaml和PV相关配置

# cat sc/templates/sc.yaml
...
        volumeMounts:
          - name: tmp-data
            mountPath: /tmp   
          - name: env-config
            mountPath: /etc/config
          - name: 1g-pv
            mountPath: /IDE0  #to be defined
          - name: podinfo
            mountPath: /etc/pod-info
  volumeClaimTemplates:
  - metadata:
      name: 1g-pv
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: standard
      resources:
        requests:
          storage: 1Gi

3、部署pod时出现问题

3.1、问题描述

# kubectl describe pods sc-0-0
Events:
  Type     Reason            Age        From               Message
  ----     ------            ----       ----               -------
  Warning  FailedScheduling    default-scheduler  0/6 nodes are available: 2 node(s) didn't find available persistent volumes to bind, 4 node(s) didn't match node selector.

3.2、问题解决

1g-pv-1.yaml位于chart中,因此需要编辑1g-pv-1.yaml,支持cinder后端

# kubectl apply -f 1g-pv-1.yaml
# cat 1g-pv-1.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: 1g-pv-1
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Delete
  storageClassName: standard
  cinder:
    volumeID: a198bce4-ba0f-4d13-8f0c-55e31212a8c9
    fsType: ext4

volumeID来自于OpenStack Cinder

# openstack volume list
| a198bce4-ba0f-4d13-8f0c-55e31212a8c9 | 1g-pv-1                                                                                     | available | 

你可能感兴趣的:(OpenStack,kubernetes)