The documentation says the following:
These default storage classes don't allow you to update the volume size once created. To enable this ability, add the
allowVolumeExpansion: true
line to one of the default storage classes, or create you own custom storage class. You can edit an existing storage class using thekubectl edit sc
command. For more information on storage classes and creating your own, see Storage options for applications in AKS.
I've tried editing the the default
YAML (which just looks like JSON and not YAML) in the Kubernetes dashboard:
{
"kind": "StorageClass",
"apiVersion": "storage.k8s.io/v1",
"metadata": {
"name": "default",
"selfLink": "/apis/storage.k8s.io/v1/storageclasses/default",
"uid": "<uid>",
"resourceVersion": "3891497",
"creationTimestamp": "2020-02-14T01:34:03Z",
"labels": {
"kubernetes.io/cluster-service": "true"
},
"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\"},\"parameters\":{\"cachingmode\":\"ReadOnly\",\"kind\":\"Managed\",\"storageaccounttype\":\"Standard_LRS\"},\"provisioner\":\"kubernetes.io/azure-disk\"}\n",
"storageclass.beta.kubernetes.io/is-default-class": "true"
}
},
"provisioner": "kubernetes.io/azure-disk",
"parameters": {
"cachingmode": "ReadOnly",
"kind": "Managed",
"storageaccounttype": "Standard_LRS"
},
"reclaimPolicy": "Delete",
"volumeBindingMode": "Immediate",
"allowVolumeExpansion": "true"
}
Which results in:
StorageClass in version "v1" cannot be handled as a StorageClass: v1.StorageClass.AllowVolumeExpansion: ReadBool: expect t or f, but found ", error found in #10 byte of ...|ansion": "true" }|..., bigger context ...|ingMode": "Immediate", "allowVolumeExpansion": "true" }|...
Also:
{
"kind": "StorageClass",
"apiVersion": "storage.k8s.io/v1",
"metadata": {
"name": "default",
"selfLink": "/apis/storage.k8s.io/v1/storageclasses/default",
"uid": "<uid>",
"resourceVersion": "3891497",
"creationTimestamp": "2020-02-14T01:34:03Z",
"labels": {
"kubernetes.io/cluster-service": "true"
},
"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\"},\"parameters\":{\"cachingmode\":\"ReadOnly\",\"kind\":\"Managed\",\"storageaccounttype\":\"Standard_LRS\"},\"provisioner\":\"kubernetes.io/azure-disk\"}\n",
"storageclass.beta.kubernetes.io/is-default-class": "true"
}
},
"provisioner": "kubernetes.io/azure-disk",
"parameters": {
"cachingmode": "ReadOnly",
"kind": "Managed",
"storageaccounttype": "Standard_LRS",
"allowVolumeExpansion": "true"
},
"reclaimPolicy": "Delete",
"volumeBindingMode": "Immediate"
}
Which results in:
StorageClass.storage.k8s.io "default" is invalid: parameters: Forbidden: updates to parameters are forbidden.
Also tried all of the following with kubectl edit sc
:
$ kubectl edit sc default allowVolumeExpansion: true
Error from server (NotFound): storageclasses.storage.k8s.io "allowVolumeExpansion:" not found
Error from server (NotFound): storageclasses.storage.k8s.io "true" not found
$ kubectl edit sc default "allowVolumeExpansion: true"
Error from server (NotFound): storageclasses.storage.k8s.io "allowVolumeExpansion: true" not found
$ kubectl edit sc/default allowVolumeExpansion: true
error: there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'kubectl get resource/<resource_name>' instead of 'kubectl get resource resource/<resource_name>'
$ kubectl edit sc/default "allowVolumeExpansion: true"
error: there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'kubectl get resource/<resource_name>' instead of 'kubectl get resource resource/<resource_name>'
What is the correct way of accomplishing this? Would be helpful if an example was in the documentation.
I do not meet the issue you got. The allowVolumeExpansion
is a property of the storage class, not the parameter and it requires the boolean value. You can see it in StorageClass.
I think you mistake setting its value. In my test, I add the property in the YAML file like this:
allowVolumeExpansion: true
Not
allowVolumeExpansion: "true"
So I think you need to change the line into this:
"allowVolumeExpansion": true