Volum Claim Template

Hi Guys

I am trying to create the cluster with volume claim template locally but I am getting error can someone help me to resolve this

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: escl1
spec:
version: 7.7.0
nodeSets:

  • name: default
    count: 1
    volumeClaimTemplates:
    • metadata:
      name: elasticsearch-data
      spec:
      accessModes:
      • ReadWriteOnce
        resources:
        requests:
        storage: 5Gi
        storageClassName: standard

Error
Error from server (Elasticsearch.elasticsearch.k8s.elastic.co "escl1" 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:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(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:5368709120, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"5Gi", Format:"BinarySI"}}}, VolumeName:"", StorageClassName:(*string)(0xc000f7e9a0), 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 cannot be modified): error when applying patch:
{"metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{"apiVersion":"elasticsearch.k8s.elastic.co/v1","kind":"Elasticsearch","metadata":{"annotations":{},"name":"escl1","namespace":"default"},"spec":{"nodeSets":[{"config":{"node.attr.attr_name":"attr_value","node.data":true,"node.ingest":true,"node.master":true,"node.store.allow_mmap":false},"count":1,"name":"default","podTemplate":{"metadata":{"labels":{"foo":"escl1"}},"spec":{"containers":[{"env":[{"name":"ES_JAVA_OPTS","value":"-Xms2g -Xmx2g"}],"name":"elasticsearch","resources":{"limits":{"cpu":1,"memory":"1Gi"}}}]}},"volumeClaimTemplates":[{"metadata":{"name":"elasticsearch-data"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"standard"}}]}],"version":"7.7.0"}}\n"}},"spec":{"nodeSets":[{"config":{"node.attr.attr_name":"attr_value","node.data":true,"node.ingest":true,"node.master":true,"node.store.allow_mmap":false},"count":1,"name":"default","podTemplate":{"metadata":{"labels":{"foo":"escl1"}},"spec":{"containers":[{"env":[{"name":"ES_JAVA_OPTS","value":"-Xms2g -Xmx2g"}],"name":"elasticsearch","resources":{"limits":{"cpu":1,"memory":"1Gi"}}}]}},"volumeClaimTemplates":[{"metadata":{"name":"elasticsearch-data"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"standard"}}]}]}}
to:
Resource: "elasticsearch.k8s.elastic.co/v1, Resource=elasticsearches", GroupVersionKind: "elasticsearch.k8s.elastic.co/v1, Kind=Elasticsearch"
Name: "escl1", Namespace: "default"
Object: &{map["apiVersion":"elasticsearch.k8s.elastic.co/v1" "kind":"Elasticsearch" "metadata":map["annotations":map["common.k8s.elastic.co/controller-version":"1.2.0" "elasticsearch.k8s.elastic.co/initial-master-nodes":"escl1-es-default-0" "kubectl.kubernetes.io/last-applied-configuration":"{"apiVersion":"elasticsearch.k8s.elastic.co/v1","kind":"Elasticsearch","metadata":{"annotations":{},"name":"escl1","namespace":"default"},"spec":{"nodeSets":[{"config":{"node.attr.attr_name":"attr_value","node.data":true,"node.ingest":true,"node.master":true,"node.store.allow_mmap":false},"count":1,"name":"default","podTemplate":{"metadata":{"labels":{"foo":"escl1"}},"spec":{"containers":[{"env":[{"name":"ES_JAVA_OPTS","value":"-Xms2g -Xmx2g"}],"name":"elasticsearch","resources":{"limits":{"cpu":1,"memory":"1Gi"}}}]}}}],"version":"7.7.0"}}\n"] "creationTimestamp":"2020-08-09T16:41:52Z" "generation":'\x03' "name":"escl1" "namespace":"default" "resourceVersion":"566306" "selfLink":"/apis/elasticsearch.k8s.elastic.co/v1/namespaces/default/elasticsearches/escl1" "uid":"8b278fa0-2871-47c6-b68a-a866f969d559"] "spec":map["auth":map "http":map["service":map["metadata":map["creationTimestamp":] "spec":map] "tls":map["certificate":map]] "nodeSets":[map["config":map["node.attr.attr_name":"attr_value" "node.data":%!q(bool=true) "node.ingest":%!q(bool=true) "node.master":%!q(bool=true) "node.store.allow_mmap":%!q(bool=false)] "count":'\x01' "name":"default" "podTemplate":map["metadata":map["labels":map["foo":"escl1"]] "spec":map["containers":[map["env":[map["name":"ES_JAVA_OPTS" "value":"-Xms2g -Xmx2g"]] "name":"elasticsearch" "resources":map["limits":map["cpu":'\x01' "memory":"1Gi"]]]]]]]] "transport":map["service":map["metadata":map["creationTimestamp":] "spec":map]] "updateStrategy":map["changeBudget":map] "version":"7.7.0"] "status":map["health":"unknown" "phase":"ApplyingChanges"]]}
for: ".\elastic.yml": admission webhook "elastic-es-validation-v1.k8s.elastic.co" denied the request: Elasticsearch.elasticsearch.k8s.elastic.co "escl1" 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:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(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:5368709120, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"5Gi", Format:"BinarySI"}}}, VolumeName:"", StorageClassName:(*string)(0xc000f7e9a0), 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 cannot be modified

The last bit of that error message is key:

Volume claim templates cannot be modified

See the docs here for more information