azure - 添加allowVolumeExpansion : true to default storage classes in AKS

标签 azure azure-storage azure-aks

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 the kubectl 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/

相关文章:

azure - Databricks Runtime 10.4 LTS - 升级后出现 AnalysisException : No such struct field id in 0, 1

azure - 将 Azure VM 迁移到其他位置

c# - 如何使用 Kubernetes 上的 Redis/ReJson 中的复杂对象中的路径更新值?

Azure Dev Spaces - 没有更多空间可用于文件同步

java - Intellij (java) 运行/调试配置 "No main class not specified"Azure Functions

c# - Azure Functions #r 仅允许在脚本中使用

azure - 对于指标警报类型,搜索查询应包含 'AggregatedValue' 和 'bin(timestamp, [roundTo])'

c# - 无法将 azure 表存储中字符串类型的实体更新为 null

powershell - 按修改日期的 Azure 存储增量复制

kubernetes - 24 小时性能测试执行突然停止在 AKS 中的 jmeter pod 中运行