K8s PVC不能绑定到PV

时间:2019-09-17 09:18:14

标签: elasticsearch kubernetes kubernetes-helm

我从掌舵稳定图中安装了弹性搜索,并陷入将pvc绑定到pc的未决状态。

我已经创建了具有与掌舵弹性PVC相同标签的PC。
 -如何将此弹性PVC绑定到PV。

enter image description here

更新配置:
PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  finalizers:
  - kubernetes.io/pvc-protection
  labels:
    app: elasticsearch
    component: data
    release: es
    role: data
  name: data-es-elasticsearch-data-0
  selfLink: /api/v1/namespaces/default/persistentvolumeclaims/data-es-elasticsearch-data-0
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
  volumeMode: Filesystem
status: {}

PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"PersistentVolume","metadata":{"annotations":{},"labels":{"type":"local"},"name":"task-pv-volume"},"spec":{"accessModes":["ReadWriteOnce"],"capacity":{"storage":"15Gi"},"hostPath":{"path":"/app/k8s-volumes"},"storageClassName":"manual"}}
  creationTimestamp: null
  finalizers:
  - kubernetes.io/pv-protection
  labels:
    app: elasticsearch
    component: data
    release: es
    role: data
    type: local
  name: task-pv-volume
  selfLink: /api/v1/persistentvolumes/task-pv-volume
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 15Gi
  hostPath:
    path: /app/k8s-volumes
    type: ""
  persistentVolumeReclaimPolicy: Retain
  storageClassName: manual
  volumeMode: Filesystem
status: {}

2 个答案:

答案 0 :(得分:2)

PersistentVolumeClaim和PersistentVolume类(非标签)必须匹配。PVC没有storageClassName,因此将PV更改为storageClassName: ''即可。

答案 1 :(得分:1)

如果您手动创建PV,我想您没有使用任何存储类。但是,您正在PV中定义存储类。因此,尝试在没有storageClassName字段的情况下重新创建PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 15Gi
  hostPath:
    path: /app/k8s-volumes
    type: ""
  persistentVolumeReclaimPolicy: Retain
  volumeMode: Filesystem