---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: filebeat-syslog-ds
  labels:
    component: filebeat-syslog
spec:
  selector:
    matchLabels:
      component: filebeat-syslog
  template:
    metadata:
      labels:
        component: filebeat-syslog
    spec:
      volumes:
        - name: filebeat-syslog-cert
          secret:
            secretName: filebeat-syslog-cert
        - name: filebeat-syslog-config
          configMap:
            name: filebeat-syslog-config
      containers:
        - name: filebeat-syslog
          image: docker.elastic.co/beats/filebeat:7.16.2-amd64
          volumeMounts:
            - name: filebeat-syslog-config
              mountPath: /usr/share/filebeat/filebeat.yml
              subPath: filebeat.yml
            - name: filebeat-syslog-config
              mountPath: /usr/share/filebeat/ilm-policy.json
              subPath: ilm-policy.json
            - name: filebeat-syslog-cert
              mountPath: /usr/share/filebeat/certs/
          env:
            - name: ELASTIC_HOST
              value: "elastic-svc"
            - name: ELASTIC_PORT
              value: "9200"
            - name: ELASTIC_USERNAME
              valueFrom:
                secretKeyRef:
                  name: filebeat-syslog-elastic-cred
                  key: username
            - name: ELASTIC_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: filebeat-syslog-elastic-cred
                  key: password
            - name: LOGSTASH_HOST
              value: "logstash-svc"
            - name: LOGSTASH_PORT
              value: "5044"
          ports:
            - name: "tcp-9000"
              protocol: TCP
              containerPort: 9000
              hostPort: 9000
            - name: "tcp-9001"
              protocol: TCP
              containerPort: 9001
              hostPort: 9001
            - name: "tcp-9002"
              protocol: TCP
              containerPort: 9002
              hostPort: 9002
            - name: "tcp-9003"
              protocol: TCP
              containerPort: 9003
              hostPort: 9003
            - name: "udp-9000"
              protocol: UDP
              containerPort: 9000
              hostPort: 9000
            - name: "udp-9001"
              protocol: UDP
              containerPort: 9001
              hostPort: 9001
            - name: "udp-9002"
              protocol: UDP
              containerPort: 9002
              hostPort: 9002
            - name: "udp-9003"
              protocol: UDP
              containerPort: 9003
              hostPort: 9003
            - name: "udp-9504"
              protocol: UDP
              containerPort: 9504
              hostPort: 9504
            - name: "udp-9506"
              protocol: UDP
              containerPort: 9506
              hostPort: 9506
