为什么它抱怨"卷声明模板只能增加其存储请求"?



我正在AWS EKS的Kubernetes上部署Elasticsearch集群。我的规格是:

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: es
spec:
version: 7.14.0
nodeSets:
- name: node
count: 2
config:
node.store.allow_mmap: false
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
storageClassName: ebs-sc
resources:
requests:
storage: 1024Gi

当我部署时,我得到了这个错误:

for: "es.yml": admission webhook "elastic-es-validation-v1.k8s.elastic.co" denied the request: Elasticsearch.elasticsearch.k8s.elastic.co "es" is invalid: spec.nodeSet[0].volumeClaimTemplates: Invalid value: []v1.PersistentVolumeClaim{v1.PersistentVolumeClaim{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"elasticsearch-data", GenerateName:"", Namespace:"", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), DeletionTimestamp:<nil>, DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry(nil)}, Spec:v1.PersistentVolumeClaimSpec{AccessModes:[]v1.PersistentVolumeAccessMode{"ReadWriteOnce"}, Selector:(*v1.LabelSelector)(nil), Resources:v1.ResourceRequirements{Limits:v1.ResourceList(nil), Requests:v1.ResourceList{"storage":resource.Quantity{i:resource.int64Amount{value:1099511627776, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"", Format:"BinarySI"}}}, VolumeName:"", StorageClassName:(*string)(0xc000cd2600), VolumeMode:(*v1.PersistentVolumeMode)(nil), DataSource:(*v1.TypedLocalObjectReference)(nil)}, Status:v1.PersistentVolumeClaimStatus{Phase:"", AccessModes:[]v1.PersistentVolumeAccessMode(nil), Capacity:v1.ResourceList(nil), Conditions:[]v1.PersistentVolumeClaimCondition(nil)}}}: volume claim templates can only have their storage requests increased, if the storage class allows volume expansion. Any other change is forbidden

规范包括用于声明持久存储的volumeClaimTemplates。我不明白为什么上面写着volume claim templates can only have their storage requests increased, if the storage class allows volume expansion

我检查过PVC是空的:

$ kubectl get pvc
No resources found in default namespace.

和我有以下规格的存储类:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: ebs-sc
provisioner: ebs.csi.aws.com
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer

另一个答案是正确的,K8s不知道如何在保留数据的同时更改存储类,因为卷也必须更改。

通过更改节点集名称,旧的节点集将消失,而新的节点集将能够从一个干净的状态产生(假设您不介意在旧的pod中保留数据)。

您可以首先将节点集重命名为新名称,让K8s刷新并生成新的pod,然后将节点集重命名为原始名称并重复。

...I don't understand why it says volume claim templates can only have their storage requests increased, if the storage class allows volume expansion.

使用ECK,当您应用引用允许卷扩展的StorageClass的规范时,您可以增加存储大小并重新应用规范。除此之外没有其他更改在volumeClaimTemplates节中允许使用。如果您必须更改volumeClaimTemplates(例如:引用不同的StorageClass,减少存储大小),您还需要在nodeSets下重命名名称并重新应用规范。示例:

...
spec:
...
nodeSets:
- name: <CHANGEME!>  # <-- MUST change if not a simple size increase
...
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
resources:
requests:
storage: <xxxGi>  # <-- Can be increased if StorageClass supports expansion. To decrease the nodeSets name MUST be changed.
storageClassName:<changeable only if nodeSets name is changed>

相关内容

  • 没有找到相关文章

最新更新