apiVersion: apps/v1beta1 kind: StatefulSet metadata: name: es labels: component: elasticsearch spec: serviceName: elasticsearch replicas: 3 #Required number of replicas template: metadata: labels: component: elasticsearch spec: initContainers: #will always initialize before other containers - name: init-sysctl image: busybox imagePullPolicy: IfNotPresent command: ["sysctl", "-w", "vm.max_map_count=262144"] securityContext: privileged: true containers: #specification of normal containers - name: es securityContext: capabilities: add: - IPC_LOCK image: quay.io/pires/docker-elasticsearch-kubernetes:5.6.4 #specifies the image of elasticsearch to install env: #List of variables accepted by ES for configuration - name: KUBERNETES_CA_CERTIFICATE_FILE value: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt - name: NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: "CLUSTER_NAME" value: "myesdb" - name: "DISCOVERY_SERVICE" value: "elasticsearch" - name: NETWORK_HOST value: "_eth0_" ports: - containerPort: 9200 name: http protocol: TCP - containerPort: 9300 name: transport protocol: TCP volumeMounts: - mountPath: /data name: storage volumeClaimTemplates: - metadata: name: storage spec: storageClassName: gp2 accessModes: [ ReadWriteOnce ] resources: requests: storage: 1Gi