0

I am installing a chart using helm but its Pod and PVC are getting stuck in pending state but I see PV are in available state.

I face this issue intermittently while installing chart

Pod describe :

Events:
  Type     Reason            Age                 From               Message
  ----     ------            ----                ----               -------
  Warning  FailedScheduling  0s (x4 over 2m17s)  default-scheduler  0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims.

PVC describe :

Name:          web-claim0
Namespace:     edge
StorageClass:  edge-custom
Status:        Pending
Volume:
Labels:        app.kubernetes.io/managed-by=Helm
               io.kompose.service=web-claim0
Annotations:   meta.helm.sh/release-name: manifest
               meta.helm.sh/release-namespace: edge
               volume.beta.kubernetes.io/storage-provisioner: docker.io/hostpath
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode:    Filesystem
Used By:       web-69bd64d5cf-lmnqd
Events:
  Type    Reason                Age                  From                         Message
  ----    ------                ----                 ----                         -------
  Normal  ExternalProvisioning  6s (x17 over 3m54s)  persistentvolume-controller  waiting for a volume to be created, either by external provisioner "docker.io/hostpath" or manually created by system administrator

I have storage class as

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: {{ .Values.prefix }}-custom
provisioner: docker.io/hostpath
reclaimPolicy: Retain
volumeBindingMode: Immediate

PVC.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: web-claim0
  name: web-claim0
spec:
  storageClassName: {{ .Values.prefix }}-custom
  selector:
    matchLabels:
      for_app: {{ .Values.prefix }}-manifest-web
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
status: {}

pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: {{ .Values.prefix }}-manifest-web-pv
  labels:
    for_app: {{ .Values.prefix }}-manifest-web
    type: local
spec:
  persistentVolumeReclaimPolicy: Retain
  storageClassName: {{ .Values.prefix }}-custom
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/{{ .Values.prefix }}-manifeststorage"

on other hand PV is in available state

Peter
  • 405
  • 3
  • 6
  • 14
  • 1
    You should not normally need to manually create a PersistentVolume or a StorageClass; the cluster should normally have a persistent volume provisioner that can create these automatically. (Even consider creating a StatefulSet rather than manually creating a PersistentVolumeClaim.) What sort of Kubernetes are you actually using, and what happens if you delete the PVC's `storageClassName:`? – David Maze Jan 26 '23 at 18:42
  • I am using AWS k8s cluster to installing it. I have business functionality to install chart which create pv,pvc,pod in custom namespace . that's why I create pv per namespace to uninstalling one will not affect other one apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: {{ .Values.prefix }}-custom storage class name value is input drive(param) – Peter Jan 26 '23 at 18:51
  • 1
    In AWS I'd normally expect the cluster to automatically create an EBS volume when it sees a PersistentVolumeClaim, and you do not need the other objects. – David Maze Jan 26 '23 at 21:58

2 Answers2

0

I had two pv,pvc with same app name due to which first pvc was getting bounded to pv which was create to other pvc. when kept unique app name specific to pv and pvc issue was resolved

Peter
  • 405
  • 3
  • 6
  • 14
0

Seems like PVC is unable to bind the PV. What you can do is you can add one claimRef block inside PV.

Something like this under the spec of pv:

claimRef:
  apiVersion: v1
  kind: PersistentVolumeClaim
  name: your pvc name that you will create after creating PV
  namespace: your namespace name

Now you need to create the pvc with the name you mentioned previously inside the mentioned namespace. It will bind as soon as you create the pvc.

SAB
  • 23
  • 5