Change the default StorageClass with Helm

1/4/2020

According to the documentation https://kubernetes.io/docs/tasks/administer-cluster/change-default-storage-class/ if wi want to change the default Storage Class we should patch it.

Template to create new Storage Class

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: encrypted
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
  fsType: ext4
  encrypted: true

I have tried to add to the template:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: gp2
  annotations:
    storageclass.kubernetes.io/is-default-class: "false"
provisioner: kubernetes.io/aws-ebs

And got an error: gp2 already exist

How to patch/update default Storage Class (make it non-default) with Helm template?

-- Yurii
aws-eks
kubernetes
kubernetes-helm

1 Answer

1/4/2020

Helm can only manage resources created by itself, and you are trying to alter an already existing resource. You can either:

  • delete the gp2 storage class before applying the chart and helm will recreate it
  • delete the gp2 template from your chart, and patch the gp2 storage class manually before applying the chart
-- Radu Mazilu
Source: StackOverflow