Search code examples
kuberneteskubernetes-helmamazon-ekskubernetes-pvc

Helm timeout for cronjob with a persistent volume


I have a Kubernetes cron job in AWS EKS that requires a persistent volume, so this is roughly what I have:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name:  pvc-{{$.Release.Name}}-tmp
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 10Gi 

Then it's mounted to a cronjob (the mount part is correct, as the following shows)

All are deployed with Helm, and a fresh deployment times out, because the PVC remains in the Pending state with the message waiting for the first consumer to be created before binding. If during the deployment I create a new job based on the cron job, the PVC is immediately bound and this and all subsequent deployment work like expected.

Is it possible to either make a PVC bind "eagerly", without a pod that requires it or, preferably, not to wait for it to get bound during the chart installation?


Solution

  • What is the storage class that you use? Storage class has volumeBindingMode attributes that controls how PV is dynamically created.

    The volumeBindingMode could be Immediate and WaitForFirstConsumer mode.

    For checking the storage class you can do kubectl get storageclass or kubectl describe storageclass. The default storage class will be used if not specified on the K8 PVC definition.

    References: