Change StorageClass of an already running cluster

You cannot change the existing storage class in an existing nodeSet.
What you can do however is rename the existing nodeSet along with the storage class modification.

For example:

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: quickstart
spec:
  version: 7.11.2
  nodeSets:
  - name: my-nodes
    count: 3
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        resources:
          requests:
            storage: 10Gi
        storageClassName: old-sc

to:

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: quickstart
spec:
  version: 7.11.2
  nodeSets:
  - name: new-nodes
    count: 3
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        resources:
          requests:
            storage: 10Gi
        storageClassName: my-new-storage-class

See how both nodeSet name and storage class name have changed in that example.

Behind the scenes, the operator will create Pods for the new nodeSet, and migrate data away from Pods of the old nodeSet before removing them. The data migration can take some time depending on how much data you have.

1 Like