apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: kibana
  labels:
    app: elasticsearch
    component: kibana
spec:
  selector:
    matchLabels:
      component: kibana
  serviceName: kibana-http
  replicas: 1
  template:
    metadata:
      labels:
        component: kibana
        http: enabled
    spec:
      securityContext:
        runAsUser: 1000
        fsGroup: 1000
      containers:
      - name: kibana
        image: docker.elastic.co/kibana/kibana:latest
        imagePullPolicy: Always
        env:
        - name: CLUSTER_NAME
          value: es-cluster
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: PROCESSORS
          valueFrom:
            resourceFieldRef:
              resource: limits.cpu
        resources:
          requests:
            cpu: "0.25"
            memory: 2Gi
          limits:
            cpu: 1
            memory: 2Gi
        ports:
        - containerPort: 5601
          name: http
        readinessProbe:
          httpGet:
            path: /api/status
            port: http
          initialDelaySeconds: 20
          timeoutSeconds: 5
        volumeMounts:
        - name: config
          mountPath: /usr/share/kibana/config
          readOnly: true
        - name: storage
          mountPath: /usr/share/kibana/data
      volumes:
      - name: config
        configMap:
          name: kibana-config
  volumeClaimTemplates:
  - metadata:
      name: storage
      annotations:
        pv.beta.kubernetes.io/gid: "1000"
    spec:
      storageClassName: glusterfs-storage
      accessModes: [ ReadWriteOnce ]
      resources:
        requests:
          storage: 1Gi
