---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kibana-dp
  labels:
    component: kibana
spec:
  replicas: 1
  selector:
    matchLabels:
      component: kibana
  template:
    metadata:
      labels:
        component: kibana
    spec:
      volumes:
        - name: kibana-cert
          secret:
            secretName: kibana-cert
      containers:
        - name: kibana
          image: docker.elastic.co/kibana/kibana:7.16.2-amd64
          env:
            - name: ELASTICSEARCH_HOSTS
              value: "[\"https://elastic-svc:9200\"]"
            - name: XPACK_SECURITY_ENABLED
              value: "true"
            - name: ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES
              value: "[\"/usr/share/kibana/config/certs/ca.crt\"]"
            - name: ELASTICSEARCH_SSL_VERIFICATIONMODE
              value: certificate
            - name: ELASTICSEARCH_USERNAME
              valueFrom:
                secretKeyRef:
                  name: kibana-elastic-cred
                  key: username
            - name: ELASTICSEARCH_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: kibana-elastic-cred
                  key: password
            - name: SERVER_SSL_ENABLED
              value: "true"
            - name: SERVER_SSL_CERTIFICATE
              value: /usr/share/kibana/config/certs/tls.crt
            - name: SERVER_SSL_KEY
              value: /usr/share/kibana/config/certs/tls.key
            - name: XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY
              valueFrom:
                secretKeyRef:
                  name: kibana-object-key
                  key: key
          volumeMounts:
            - name: kibana-cert
              mountPath: /usr/share/kibana/config/certs
              readOnly: true
          ports:
            - containerPort: 5601
