K8s PVC不能绑定PV

论道 发表于: 2019-09-17   最后更新时间: 2019-09-17  

我从helm stable chart安装elasticsearch,现在卡在了pvc到pc。

我已经创建了一个与helm elastic的PVC相同标签的PC。

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: {}

怎么样将这种pvc绑定到pv?



您需要解锁本帖隐藏内容请: 点击这里
本帖隐藏的内容




上一条: 为什么Kubernetes Ingress不收流量?
下一条: kubernetes安装Istio服务及其使用问题

  • 如果你手动创建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
    

    PersistentVolumeClaimPersistentVolume(不是标签)必须匹配。
    你的PVC没有storageClassName,因此将PV更改为storageClassName:''应该就可以了。