documentation说如下:
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.
我尝试在 Kubernetes 仪表板中编辑默认
YAML(它看起来像 JSON,而不是 YAML):
{
"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"
}
结果是:
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" }|...
另外:
{
"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"
}
结果是:
StorageClass.storage.k8s.io "default" is invalid: parameters: Forbidden: updates to parameters are forbidden.
还使用 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>'
实现这一目标的正确方法是什么?如果文档中包含示例将会很有帮助。
最佳答案
我没有遇到您遇到的问题。 allowVolumeExpansion
是存储类的属性,而不是参数,它需要 bool 值。您可以在 StorageClass 中看到它.
我认为你错误地设置了它的值。在我的测试中,我在 YAML 文件中添加了如下属性:
allowVolumeExpansion: true
不是
allowVolumeExpansion: "true"
所以我认为你需要将行更改为:
"allowVolumeExpansion": true
关于azure - 添加allowVolumeExpansion : true to default storage classes in AKS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60287163/