Prerequisite

Installing Kubernetes Make sure that persistent volumn is created

Installation Steps

official doc

kubectl get nodes # to check nodes
kubectl describe nodes # to details of node, make sure there no warnings and issues
kubectl get pods # to see all the pods
  1. Install Custom Resource Definitions and the Operator with Role Based Access Control
kubectl create -f https://download.elastic.co/downloads/eck/1.7.0/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/1.7.0/operator.yaml
  1. Monitor Operator
kubectl -n elastic-system logs -f statefulset.apps/elastic-operator
  1. Create storage class
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
  1. Create Persistence Volume - not required Note: `/shared01/volumes/pv1` is NFS mounted on all workers and masters. Do not create persitence volume, ref, just create a storage class, even PV will be created by the elastic operator (controller)
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv-1
  labels:
    type: nfs-local
spec:
  capacity:
    storage: 20Gi
  accessModes:
#    - ReadWriteOnce
     - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  hostPath:
    path: "/shared01/volumes/pv1"
  1. Deploy an Elasticsearch cluster
    • Check Storage Classes

      kubectl get storageclasses # describe for details
      
    • Check

kubectl get pv
kubectl get pvc # claim
NAME       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS     CLAIM                                                STORAGECLASS    REASON   AGE
nfs-pv-1   400Gi      RWO            Retain           Released   default/elasticsearch-data-quickstart-es-default-0   local-storage            2d18h

storageclass.yaml

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
#volumeBindingMode: Immediate
allowVolumeExpansion: true

Create storage class

kubectl apply -f storageclass.yaml

elasticsearch-cluster.yaml

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: quickstart
spec:
  version: 7.13.4
  nodeSets:
  - name: default
    count: 1
    config:
      node.store.allow_mmap: false
    # below config is extra to use local-storage PV
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 50Gi
        storageClassName: local-storage

apply manifest

kubectl apply -f elasticsearch-cluster.yaml