apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: elasticsearch-logging
  labels:
    k8s-app: elasticsearch-logging
#    version: v5.6.4
    version: v6.3.0
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
spec:
  serviceName: elasticsearch-logging
  replicas: 1
  selector:
    matchLabels:
      k8s-app: elasticsearch-logging
#      version: v5.6.4
      version: v6.3.0
  template:
    metadata:
      labels:
        k8s-app: elasticsearch-logging
#        version: v5.6.4
        version: v6.3.0
        kubernetes.io/cluster-service: "true"
    spec:
#      nodeSelector:
#        elastichost: "true"
      containers:
#        - image: k8s.gcr.io/elasticsearch:v5.6.4
        - image: k8s.gcr.io/elasticsearch:v6.3.0
          name: elasticsearch-logging
          resources:
            # need more cpu upon initialization, therefore burstable class
            limits:
              cpu: 1000m
            requests:
              cpu: 100m
          ports:
            - containerPort: 9200
              name: db
              protocol: TCP
            - containerPort: 9300
              name: transport
              protocol: TCP
          volumeMounts:
            - name: es-pvc-volume
              mountPath: /data
          env:
            - name: MINIMUM_MASTER_NODES
              value: "1"
            - name: "NAMESPACE"
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
      volumes:
        - name: es-pvc-volume
          persistentVolumeClaim:
            claimName: elasticsearch-logging-claim
      # Elasticsearch requires vm.max_map_count to be at least 262144.
      # If your OS already sets up this number to a higher value, feel free
      # to remove this init container.
      initContainers:
        - image: alpine:3.6
          command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
          name: elasticsearch-logging-init
          securityContext:
            privileged: true

