apiVersion: apps/v1
kind: Deployment
metadata:
  name: kibana
  namespace: elastic
  labels:
    app: kibana
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kibana
  template:
    metadata:
      labels:
        app: kibana
    spec:
      initContainers:
        - name: wait-for-elasticsearch
          image: appropriate/curl
          resources:
            limits:
              cpu: 150m
              memory: 50Mi
            requests:
              cpu: 150m
              memory: 50Mi
          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          args:
          - "sh"
          - "-c"
          - "while [ $(curl -sw %{http_code} http://elasticsearch-0.elasticsearch.${NAMESPACE}.svc.cluster.local:9200/_cluster/health?pretty -o /dev/null) -ne 200 ]; do sleep 15; done"
      containers:
        - name: kibana
          image: docker.elastic.co/kibana/kibana:6.8.0
          ports:
          - containerPort: 5601
            name: http
            protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /api/status
              port: http
              scheme: HTTP
            initialDelaySeconds: 20
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
          resources: 
            limits:
              cpu: 500m
              memory: 768Mi
            requests:
              cpu: 100m
              memory: 512Mi
          volumeMounts:
            - name: kibana-config
              mountPath: /usr/share/kibana/kibana.yml
              subPath: kibana.yml
      volumes:
        - name: kibana-config
          configMap:
            name: kibana-config