apiVersion: apps/v1
kind: Deployment
metadata:
  name: telegraf-deployment
spec:
  selector:
    matchLabels:
      app: telegraf
  minReadySeconds: 5
  template:
    metadata:
      labels:
        app: telegraf
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/port: '9273'
    spec:
      containers:
        - image: telegraf
          name: telegraf
          args:
          - --config
          - /etc/telegraf/telegraf.conf
          - --watch-config
          - inotify
          volumeMounts:
            - mountPath: /etc/telegraf/
              name: telegraf-config
              readOnly: true
          env:
          - name: CONF_ID
            value: "2"
          - name: MYSQL_HOST
            value: "mysql"
          - name: MYSQL_PORT
            value: "3306"
          - name: MYSQL_USER
            valueFrom:
              secretKeyRef:
                name: telegraf-secrets
                key: MYSQL_USER
          - name: MYSQL_PASSWORD
            valueFrom:
              secretKeyRef:
                name: telegraf-secrets
                key: MYSQL_PASSWORD
      volumes:
        - name: telegraf-config
          configMap:
            name: telegraf-config
