---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: swisnap-agent-ds
  labels:
    daemon: swisnap-agent-ds
spec:
  selector:
    matchLabels:
      daemon: swisnap-agent-ds
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      name: swisnap-agent-ds
      labels:
        daemon: swisnap-agent-ds
    spec:
      tolerations:
        - key: node-role.kubernetes.io/master
          effect: NoSchedule
      containers:
        - name: swisnap-agent-ds
          image: solarwinds/solarwinds-snap-agent-docker:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 21413
              protocol: TCP
          env:
            - name: APPOPTICS_HOSTNAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: APPOPTICS_TOKEN
              valueFrom:
                secretKeyRef:
                  name: appoptics-token
                  key: APPOPTICS_TOKEN
                  optional: true
            - name: SOLARWINDS_TOKEN
              valueFrom:
                secretKeyRef:
                  name: solarwinds-token
                  key: SOLARWINDS_TOKEN
                  optional: true
            - name: LOGGLY_TOKEN
              valueFrom:
                secretKeyRef:
                  name: loggly-token
                  key: LOGGLY_TOKEN
                  optional: true
            - name: PAPERTRAIL_TOKEN
              valueFrom:
                secretKeyRef:
                  name: papertrail-token
                  key: PAPERTRAIL_TOKEN
                  optional: true
            - name: PAPERTRAIL_HOST
              valueFrom:
                secretKeyRef:
                  name: papertrail-publisher-settings
                  key: PAPERTRAIL_HOST
                  optional: true
            - name: PAPERTRAIL_PORT
              valueFrom:
                secretKeyRef:
                  name: papertrail-publisher-settings
                  key: PAPERTRAIL_PORT
                  optional: true
          envFrom:
            - configMapRef:
                name: swisnap-host-configmap
          volumeMounts:
            - name: docker-sock
              mountPath: /var/run/docker.sock
            - name: proc
              mountPath: /host/proc
              readOnly: true
            - name: cgroup
              mountPath: /sys/fs/cgroup
          resources:
            limits:
              cpu: 200m
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 256Mi
          livenessProbe:
            httpGet:
              path: /v1/plugins
              port: 21413
            initialDelaySeconds: 10
            timeoutSeconds: 5
          readinessProbe:
            httpGet:
              path: /v1/plugins
              port: 21413
            initialDelaySeconds: 10
            timeoutSeconds: 5
      volumes:
        - name: docker-sock
          hostPath:
            path: /var/run/docker.sock
        - name: proc
          hostPath:
            path: /proc
        - name: cgroup
          hostPath:
            path: /sys/fs/cgroup
