---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: logstash-dp
  labels:
    component: logstash
spec:
  replicas: 2
  selector:
    matchLabels:
      component: logstash
  template:
    metadata:
      labels:
        component: logstash
    spec:
      volumes:
        - name: logstash-cert
          secret:
            secretName: logstash-cert
        - name: logstash-pipeline-config
          configMap:
            name: logstash-pipeline-config
      containers:
        - name: logstash
          image: docker.elastic.co/logstash/logstash:7.16.2-amd64
          env:
            - name: ES_JAVA_OPTS
              value: "-Xms1g -Xmx1g"
            - name: ELASTIC_URI
              value: "https://elastic-svc:9200"
            - name: XPACK_MONITORING_ELASTICSEARCH_HOSTS
              value: "[\"https://elastic-svc:9200\"]"
            - name: XPACK_MONITORING_ELASTICSEARCH_SSL_CERTIFICATE_AUTHORITY
              value: /usr/share/logstash/certs/ca.crt
            - name: XPACK_MONITORING_ELASTICSEARCH_USERNAME
              valueFrom:
                secretKeyRef:
                  name: logstash-elastic-cred
                  key: username
            - name: XPACK_MONITORING_ELASTICSEARCH_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: logstash-elastic-cred
                  key: password
            - name: ELASTIC_USERNAME
              valueFrom:
                secretKeyRef:
                  name: logstash-elastic-cred
                  key: username
            - name: ELASTIC_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: logstash-elastic-cred
                  key: password
          volumeMounts:
            - name: logstash-cert
              mountPath: /usr/share/logstash/certs/
              readOnly: true
            - name: logstash-pipeline-config
              mountPath: /usr/share/logstash/pipeline
          ports:
            - containerPort: 5044
