apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: loadgen-telemetry
  namespace: scalyr-loadgen
spec:
  selector:
    matchLabels:
      app: loadgen-telemetry
  template:
    metadata:
      labels:
        app: loadgen-telemetry
    spec:
      serviceAccountName: scalyr-service-account
      containers:
      - name: scalyr-agent
        image:  scalyr/scalyr-k8s-agent:2.1.3
        imagePullPolicy: Always
        env:
          - name: SCALYR_API_KEY
            valueFrom:
              secretKeyRef:
                name: loadgen-api-keys
                key: telemetry-write-logs-key
          - name: SCALYR_K8S_NODE_NAME
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
          - name: SCALYR_K8S_POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: SCALYR_K8S_POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: SCALYR_K8S_POD_UID
            valueFrom:
              fieldRef:
                fieldPath: metadata.uid
          - name: SCALYR_K8S_KUBELET_HOST_IP
            valueFrom:
              fieldRef:
                fieldPath: status.hostIP
          - name: SCALYR_CONTAINER_GLOBS
            value: "*-telemetry*"
          - name: SCALYR_K8S_INCLUDE_NAMESPACES
            value: "scalyr-loadgen"
          - name: SCALYR_K8S_EVENTS_DISABLE
            value: "true"
          - name: SCALYR_REPORT_CONTAINER_METRICS
            value: "false"
          - name: SCALYR_K8S_REPORT_CONTAINER_METRICS
            value: "false"
        envFrom:
          - configMapRef:
              name: loadgen-telemetry-configmap
        resources:
          limits:
            memory: 500Mi
        volumeMounts:
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
        - name: varlogpods
          mountPath: /var/log/pods
          readOnly: true
        - name: varlogcontainers
          mountPath: /var/log/containers
          readOnly: true
        - name: dockersock
          mountPath: /var/scalyr/docker.sock
      volumes:
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers
      - name: varlogpods
        hostPath:
          path: /var/log/pods
      - name: varlogcontainers
        hostPath:
          path: /var/log/containers
      - name: dockersock
        hostPath:
          path: /var/run/docker.sock
      # comment this section if you do not want to run on the master
      tolerations:
      - key: "node-role.kubernetes.io/master"
        operator: "Exists"
        effect: "NoSchedule"
