Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set a different default storage class #118

Closed
rtyler opened this issue Jan 11, 2018 · 30 comments
Closed

Cannot set a different default storage class #118

rtyler opened this issue Jan 11, 2018 · 30 comments

Comments

@rtyler
Copy link

rtyler commented Jan 11, 2018

#48 was resolved, and believe the upgrade I performed a week or two ago from Kubernetes 1.8.1 to 1.8.2 caused the "fix" to come into effect.

Unfortunately I had already set managed-premium as the IsDefaultClass, and now AKS has two default storage classes set:

Name:            default
IsDefaultClass:  Yes
Annotations:     kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1beta1","kind":"StorageClass","metadata":{"annotations":{"storageclass.beta.kubernetes.io/is-default-class":"true"},"labels":{"kubernetes.io/cluster-service":"true"},"name":"default","namespace":""},"parameters":{"kind":"Managed","storageaccounttype":"Standard_LRS"},"provisioner":"kubernetes.io/azure-disk"}
,storageclass.beta.kubernetes.io/is-default-class=true
Provisioner:  kubernetes.io/azure-disk
Parameters:   kind=Managed,storageaccounttype=Standard_LRS
Events:       <none>


Name:            managed-premium
IsDefaultClass:  Yes
Annotations:     kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1beta1","kind":"StorageClass","metadata":{"annotations":{},"labels":{"kubernetes.io/cluster-service":"true"},"name":"managed-premium","namespace":""},"parameters":{"kind":"Managed","storageaccounttype":"Premium_LRS"},"provisioner":"kubernetes.io/azure-disk"}
,storageclass.kubernetes.io/is-default-class=true
Provisioner:  kubernetes.io/azure-disk
Parameters:   kind=Managed,storageaccounttype=Premium_LRS
Events:       <none>

I don't know if this is a transitory issue when upgrading from 1.8.1 to 1.8.2, but any change which adjusts the storage clases should check that a default storage class has not already been set.

@rtyler
Copy link
Author

rtyler commented Jan 11, 2018

Of course, two default storageclasses causes a problem, in case that wasn't already obvious:

create Claim jenkins-dduportal-jenkins-dduportal-0 for Pod jenkins-dduportal-0 in StatefulSet jenkins-dduportal failed error: persistentvolumeclaims "jenkins-dduportal-jenkins-dduportal-0" is forbidden: Internal error occurred: 2 default StorageClasses were found 

@rtyler rtyler changed the title Upgrade should consider whether a default StorageClass has already been set. Cannot set a different default storage class Jan 11, 2018
@rtyler
Copy link
Author

rtyler commented Jan 11, 2018

I've attempted to correct this a few times, but it appears that I cannot unset default as the default storage class.

wut.

@andyzhangx
Copy link
Contributor

what's the result of

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

it does not work?

@rtyler
Copy link
Author

rtyler commented Jan 12, 2018

If you check the storage class after a minute or two, you should observe that it has returned to it's default state:

➜  codevalet git:(master) ✗ KUBECONFIG=$PWD/.kube/config ~/bin/kubectl patch storageclass default -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
storageclass "default" patched
➜  codevalet git:(master) ✗ KUBECONFIG=$PWD/.kube/config ~/bin/kubectl describe storageclass default                                                                              
Name:            default
IsDefaultClass:  Yes
Annotations:     kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1beta1","kind":"StorageClass","metadata":{"annotations":{"storageclass.beta.kubernetes.io/is-default-class":"true"},"labels":{"kubernetes.io/cluster-service":"true"},"name":"default","namespace":""},"parameters":{"kind":"Managed","storageaccounttype":"Standard_LRS"},"provisioner":"kubernetes.io/azure-disk"}
,storageclass.beta.kubernetes.io/is-default-class=true,storageclass.kubernetes.io/is-default-class=false
Provisioner:  kubernetes.io/azure-disk
Parameters:   kind=Managed,storageaccounttype=Standard_LRS
Events:       <none>

@rabenhorst
Copy link

I just observed the exact same behavior.

@andyzhangx
Copy link
Contributor

I just realized that the built-in storage class are all in /etc/kubernetes/addons/azure-storage-classes.yaml in master node, unless you could change this file, otherwise you could not change the default setting. The point is you could not access file /etc/kubernetes/addons/azure-storage-classes.yaml...
@slack

@jzakotnik
Copy link

We observe the same issue. Workaround is to change the file above.
@gonzochick

@jimmykarily
Copy link

Let me just link the 2 issues (they are similar): kubernetes/kubernetes#53428

@seanknox
Copy link
Contributor

seanknox commented Aug 2, 2018

Closing due inactivity. Feel free to re-open if still an issue.

@seanknox seanknox closed this as completed Aug 2, 2018
@kwaazaar
Copy link

kwaazaar commented Mar 11, 2019

Why is this closed? The proposed fix requires me to change config on the master, but with AKS my master is managed (away), so how could this work? I really like to specify my own default storage class, so I have a little more control. Currently I cannot.

@ddarling85
Copy link

Hello, has anyone been able to get around this issue yet? I just attempted to change my default storage class also. Is there a way to dynamically assign storage using the default class?

@stevendstark
Copy link

Hello, I'm also running into the same issue. Has anyone been able to change the default storage class from AKS?

@huangyingting
Copy link

@andyzhangx and @jnoller , do we have any updates on this to change default storageclass from AKS?

@sharkymcdongles
Copy link

I also need a fix for this @andyzhangx pretty plz <3

@andyliddle
Copy link

is there any fix for this yet? I don't want azure-disk to be default in my cluster

@gkaleta
Copy link

gkaleta commented Feb 19, 2020

@andyzhangx @jnoller can you follow up on this? @palma21 FYI

@palma21 palma21 self-assigned this Apr 21, 2020
@berndverst
Copy link
Member

Just adding my thoughts here -- for plenty of use cases, including KubeFlow, it would be preferable to change the default storage class.

For example in KubeFlow I would prefer using Azure Files (which I can mount as Read Write Many) instead of Azure Disks that can only be attached to a single node.

@sblack4
Copy link

sblack4 commented May 12, 2020

This looks like a duplicate of #1075, but the good news is it's been added to the roadmap :) https://github.com/Azure/AKS/projects/1#card-34416796

@andyzhangx
Copy link
Contributor

andyzhangx commented May 13, 2020

Here is the way how to change the default storage class on AKS:

  • prepare default storage class and save to your local env, e.g. default.yaml
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.beta.kubernetes.io/is-default-class: "true"
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
    kubernetes.io/cluster-service: "true"
  name: default
parameters:
  cachingmode: ReadOnly
  kind: Managed
  storageaccounttype: Premium_LRS
provisioner: kubernetes.io/azure-disk
reclaimPolicy: Delete
volumeBindingMode: Immediate
  • Run following two commands consecutively:
kubectl delete sc default && kubectl apply -f default.yaml
  • check whether default storage class is changed:
kubectl get sc default -o yaml

By this way, you could change other built-in storage classes too.

@berndverst
Copy link
Member

@andyzhangx I'm pretty sure this is exactly what I tried multiple times but it didn't work.

If I do kubectl get sc default -o yaml everything is fine, but once I run kubectl get sc it has reverted.

@andyzhangx
Copy link
Contributor

andyzhangx commented Jun 8, 2020

@andyzhangx I'm pretty sure this is exactly what I tried multiple times but it didn't work.

If I do kubectl get sc default -o yaml everything is fine, but once I run kubectl get sc it has reverted.

@berndverst what's your aks version? I tried on AKS 1.16 and 1.17 clusters, it works as expected. The key point is run following two command immediately:

kubectl delete sc default && kubectl apply -f default.yaml

@DanielSCon40
Copy link

@andyzhangx we are using v1.16.9 and it still does revert to initial state. Now I have two defaults.

@andyzhangx
Copy link
Contributor

@andyzhangx we are using v1.16.9 and it still does revert to initial state. Now I have two defaults.

pls make sure you have prepared default.yaml file first(see above example: #118 (comment)) and then run following command:

kubectl delete sc default && kubectl apply -f default.yaml

And if you run kubectl delete sc default first and run kubectl apply -f default.yaml command after a while, it may not work. Pls make sure kubectl delete and kubectl apply command runs consecutively. Also when there is cluster upgrade, the default class setting would be reverted. So this is only a workaround.

@egoienola
Copy link

egoienola commented Jul 17, 2020

Having tested it with 1.16, 1.17 and 1.18, I can confirm that any changes I make to the default sc get reverted within a minute. This is true for all storage classes provided by AKS. e.g. azurefile.

$ kubectl get sc
NAME                PROVISIONER                RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
azurefile           kubernetes.io/azure-file   Delete          Immediate           true                   37m
azurefile-premium   kubernetes.io/azure-file   Delete          Immediate           true                   37m
default (default)   kubernetes.io/azure-disk   Delete          Immediate           true                   37m
managed-premium     kubernetes.io/azure-disk   Delete          Immediate           true                   37m

$ kubectl describe sc azurefile
Name:            azurefile
IsDefaultClass:  No
Annotations:     kubectl.kubernetes.io/last-applied-configuration={"allowVolumeExpansion":true,"apiVersion":"storage.k8s.io/v1beta1","kind":"StorageClass","metadata":{"annotations":{},"labels":{"kubernetes.io/cluster-service":"true"},"name":"azurefile"},"parameters":{"skuName":"Standard_LRS"},"provisioner":"kubernetes.io/azure-file"}

Provisioner:           kubernetes.io/azure-file
Parameters:            skuName=Standard_LRS
AllowVolumeExpansion:  True
MountOptions:          <none>
ReclaimPolicy:         Delete
VolumeBindingMode:     Immediate
Events:                <none>

$ cat << 'EOF' > azurefile.yaml
> kind: StorageClass
> apiVersion: storage.k8s.io/v1
> metadata:
>   name: azurefile
> provisioner: kubernetes.io/azure-file
> mountOptions:
>   - dir_mode=0777
>   - file_mode=0777
>   - uid=1001
>   - gid=1001
> parameters:
>   skuName: Standard_LRS
> EOF

$ kubectl delete sc azurefile && kubectl apply -f azurefile.yaml
storageclass.storage.k8s.io "azurefile" deleted
storageclass.storage.k8s.io/azurefile created

$ date
Tue Jul 14 11:40:49 EDT 2020

$ kubectl delete sc azurefile && kubectl apply -f azurefile.yaml
storageclass.storage.k8s.io "azurefile" deleted
storageclass.storage.k8s.io/azurefile created
sukezg@cldlgn05:~/viya4-azure$ kubectl describe sc azurefile
Name:            azurefile
IsDefaultClass:  No
Annotations:     kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"azurefile"},"mountOptions":["dir_mode=0777","file_mode=0777","uid=1001","gid=1001"],"parameters":{"skuName":"Standard_LRS"},"provisioner":"kubernetes.io/azure-file"}

Provisioner:           kubernetes.io/azure-file
Parameters:            skuName=Standard_LRS
AllowVolumeExpansion:  <unset>
MountOptions:
  dir_mode=0777
  file_mode=0777
  uid=1001
  gid=1001
ReclaimPolicy:      Delete
VolumeBindingMode:  Immediate
Events:             <none>

$ date
Tue Jul 14 11:41:50 EDT 2020

$ kubectl describe sc azurefile
Name:            azurefile
IsDefaultClass:  No
Annotations:     kubectl.kubernetes.io/last-applied-configuration={"allowVolumeExpansion":true,"apiVersion":"storage.k8s.io/v1beta1","kind":"StorageClass","metadata":{"annotations":{},"labels":{"kubernetes.io/cluster-service":"true"},"name":"azurefile"},"parameters":{"skuName":"Standard_LRS"},"provisioner":"kubernetes.io/azure-file"}

Provisioner:           kubernetes.io/azure-file
Parameters:            skuName=Standard_LRS
AllowVolumeExpansion:  True
MountOptions:          <none>
ReclaimPolicy:         Delete
VolumeBindingMode:     Immediate
Events:                <none>

Note how in a matter of 1 minute, all my MountOptions customisations get reverted back. I encounter the exact same behaviour trying to modify the default sc, so have to end up creating a new sc and patching all my resources accordingly.

@ghost ghost added the action-required label Aug 11, 2020
@danishsamad
Copy link

I have the same issue. Changing the default storage class only lasts for a minute or so, reverting back to using the default storage class ending in two storage classes marked as default

@sharkymcdongles
Copy link

sharkymcdongles commented Sep 14, 2020 via email

@andyzhangx
Copy link
Contributor

Update: original storage class is set as addonmanager.kubernetes.io/mode=Reconcile, we are now switching to use addonmanager.kubernetes.io/mode=EnsureExists, the rollout would happen next Monday, it could be completed in around Mid Oct.
Try to use a non default storage class now is the workaround.

@andyzhangx
Copy link
Contributor

andyzhangx commented Oct 14, 2020

With the fix roll out, here is the way how to change the default storage class on AKS:

  • prepare default storage class and save to your local env, e.g. default.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    storageclass.beta.kubernetes.io/is-default-class: "true"
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
    kubernetes.io/cluster-service: "true"
  name: default
parameters:
  storageaccounttype: Premium_LRS
provisioner: disk.csi.azure.com
allowVolumeExpansion: true
reclaimPolicy: Delete
volumeBindingMode: Immediate
  • Run following two commands consecutively:
kubectl delete sc default && kubectl apply -f default.yaml
  • check whether default storage class is changed:
kubectl get sc default -o yaml

You could also use same way to to change other built-in storage classes, make sure storageclass.beta.kubernetes.io/is-default-class: "true" is removed in the new storage class config.

  • Check whether your default class addonmanager setting is correct(should be EnsureExists other than Reconcile):
# k get sc default -o yaml | grep addonmanager
    addonmanager.kubernetes.io/mode: EnsureExists

@andyzhangx
Copy link
Contributor

@palma21

@ghost ghost locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests