How do i change the default StorageClass

0 votes
The pre-installed default StorageClass doesn't not fit  with my application's workload. So, I want change the default StorageClass. I tried  deleting the default StorageClass, but this doesn't seem to work. It's still configured with the default StorageClass. How do i change this?

Please Help.
Jul 23, 2019 in Kubernetes by Namik
• 1,230 points
3,936 views

1 answer to this question.

0 votes

Simply deleting the default StorageClass may not work, as it may be re-created automatically by the addon manager running in your cluster. 

you might need to consult the docs for your installation for details about addon manager and how to disable individual addons.

Changing the default StorageClass :

  1. List the StorageClasses in your cluster:

    kubectl get storageclass
    
    

    The output is similar to this:

    NAME                 PROVISIONER               AGE
    standard (default)   kubernetes.io/gce-pd      1d
    gold                 kubernetes.io/gce-pd      1d

    The default StorageClass is marked by (default).

  2. Mark the default StorageClass as non-default:

    The default StorageClass has an annotation storageclass.kubernetes.io/is-default-class set to true. Any other value or absence of the annotation is interpreted as false.

    To mark a StorageClass as non-default, you need to change its value to false:

      kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

    where <your-class-name> is the name of your chosen StorageClass.

  3. Mark a StorageClass as default:

    Similarly to the previous step, you need to add/set the annotation storageclass.kubernetes.io/is-default-class=true.

      kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

    Please note that at most one StorageClass can be marked as default. If two or more of them are marked as default, a PersistentVolumeClaim without storageClassName explicitly specified cannot be created.

  4. Verify that your chosen StorageClass is default:

    kubectl get storageclass

    The output is similar to this:

      NAME             PROVISIONER               AGE
      standard         kubernetes.io/gce-pd      1d
      gold (default)   kubernetes.io/gce-pd      1d
answered Jul 23, 2019 by Sirajul
• 59,230 points

Related Questions In Kubernetes

0 votes
1 answer

How do I create a service account for my dashboard and get all the credentails

Run the following commands: This command will create ...READ MORE

answered Oct 8, 2018 in Kubernetes by Kalgi
• 52,350 points
1,707 views
0 votes
1 answer

How do I determine the status of a Deployment? - Kubernetes

Use kubectl get deployment <deployment>. If the ...READ MORE

answered Jul 25, 2019 in Kubernetes by Harsha
746 views
0 votes
2 answers

How do I update all my pods if the image changed but the tag is the same? - Kubernetes

Make sure your imagePullPolicy is set to Always(this is the ...READ MORE

answered Aug 6, 2019 in Kubernetes by Sirajul
• 59,230 points
3,487 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,476 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 views
0 votes
2 answers

How do I update all my pods if the image is changed but the tag is the same?

since K8s 1.15 kubectl rollout restart do the ...READ MORE

answered Jul 24, 2020 in Kubernetes by Mathieu V
7,199 views
0 votes
1 answer

How do I expose a service to a host outside the cluster?

There are two ways by which we ...READ MORE

answered Jul 12, 2019 in Kubernetes by Sirajul
• 59,230 points
800 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP