my helm apps won’t deploy because of pvc issues

by Mar 22, 2021vSphere With Tanzu

Today I was playing around with vSphere with Tanzu. I want to consume vSphere with Tanzu and therefore I try to deploy an app from the bitnami repository. This should be pretty easy to do. Well I’m still in the learning phase so bear with me if this is something obvious …

These are the steps I’m doing

  • Install helm
  • Add bitnami repo
  • Install app from the bitnami repo
  • Deploy an app from the bitnami repo on a Tanzu Kubernetes Grid (TKG) cluster (deployed on vSphere with Tanzu)

So I tried to deploy redis to the TKG cluster. It needs a Persistent Volume (PV) so at deploy time a Persistent Volume Claim (PVC) would be issued and a PV should be assigned. When I saw it took a while to get my redis app deployed I looked at the namespace – Monitor – Events – Kubernetes and saw that there was an error: ‘no persistent volumes available for this claim and no storage class is set’.

Persistent Volume Claim failure
Overview Persistent Volume Claims

Ok that is that, but what does that mean? I had no clue, so I just googled and came to @anthonyspiteri his blog post https://anthonyspiteri.net/no-persistent-volumes-available-claim-storage-class/ which shows that you can get around this by either specifying the storage class at helm install time or patching the TKG cluster.

In my case the issue was that I did not specify the defaultClass when I created the TKG cluster. I used the following yaml file to create the TKG cluster. The highlighted lines were not in the yaml file when I created the TKG cluster and these specify what storage class should be used by default.

apiVersion: run.tanzu.vmware.com/v1alpha1
kind: TanzuKubernetesCluster
metadata:
  name: k8s-01
  namespace: demo
spec:
  topology:
    controlPlane:
      count: 1
      class: guaranteed-small
      storageClass: storage-policy-tanzu
    workers:
      count: 3
      class: guaranteed-small
      storageClass: storage-policy-tanzu
  settings:
    storage:
      defaultClass: storage-policy-tanzu
  distribution:
    version: v1.18
ShellSession

So I executed (the k8s-01.yaml file has the above content)

kubectl apply -f k8s-01.yaml
ShellSession

and received the following error:

error: unable to recognize "k8s-01.yaml": no matches for kind "TanzuKubernetesCluster" in version "run.tanzu.vmware.com/v1alpha1"
TanzuKubernetesCluster error

As I was still in the TKG cluster context I could not change the TKG cluster spec. So I need to change the context to the namespace ‘demo’ (where I deployed my TKG cluster)

kubectl config use-context demo
ShellSession

I reapplied the yaml file, changed the context again to the TKG cluster and issued the command:

kubectl describe storageclass
ShellSession

Now we see that there is a default storage class for this cluster:

Cluster default storage class changed

And when I launch the deploy again:

kubectl run redis bitnami/redis
ShellSession

I see that the deploy is succeeding. Woohoo

UPDATE: @anthonyspiteri has come to the same conclusion in later blog posts