# This file is intended to be used as a template.
# Only copy the spec, and merge it into your pod's deployment
# Update the ConfigMap name reference accordingly

apiVersion: apps/v1
kind: Deployment
metadata:
  name: telegraf
spec:
  replicas: 1
  selector:
    matchLabels:
      app: APPLICATION
  template:
    metadata:
      labels:
        app: APPLICATION
    spec:
      containers:

      # ***********************************************************************************************************
      # Copy / Merge the following container into your Deployement / Statefuleset definition as a sidecar container
      # ***********************************************************************************************************


      # **************************
      # Start Container Definition
      # **************************
      - name: telegraf
        image: wavefronthq/telegraf-sidecar
        ports:
        - name: udp-statsd
          containerPort: 8125
        - name: udp-8092
          containerPort: 8092
        - name: tcp-8094
          containerPort: 8094
        env:
        - name: WAVEFRONT_PROXY
          value: wavefront-proxy
        - name: WAVEFRONT_PROXY_PORT
          value: "2878"
        - name: INTERVAL
          value: 60s
        - name: METRIC_SOURCE_NAME
          # This can be change to use the Deployment / Statefulset name instead as a simple value
          # The metric source name should not be an ephemeral value
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: NODE_HOSTNAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        resources:
          requests:
            memory: 30Mi
            cpu: 100m
          limits:
            memory: 50Mi
            cpu: 200m
        volumeMounts:
        - name: telegraf-d
          mountPath: /etc/telegraf/telegraf.d            
      # ************************
      # End Container Definition
      # ************************


      volumes:

      # ***********************
      # Start Volume Definition
      # ***********************
      - name: telegraf-d
        projected:
          sources:
          - configMap:
              name: telegraf-APPLICATION-config
      # *********************
      # End Volume Definition
      # *********************
