---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: swisnap-agent-k8s-event-collector
  namespace: kube-system
  labels:
    app: swisnap-agent-k8s-event-collector
spec:
  replicas: 1
  selector:
    matchLabels:
      app: swisnap-agent-k8s-event-collector
  template:
    metadata:
      labels:
        app: swisnap-agent-k8s-event-collector
    spec:
      serviceAccountName: swisnap-events-agent-serviceaccount
      containers:
        - name: swisnap-agent-k8s-event-collector
          image: 'solarwinds/solarwinds-snap-agent-docker:latest'
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: task-logs-k8s-events
              mountPath: /opt/SolarWinds/Snap/etc/tasks-autoload.d/task-logs-k8s-events.yaml
              subPath: task-logs-k8s-events.yaml
          env:
            - 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-agent-k8s-events-configmap
          resources:
            limits:
              cpu: 200m
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 256Mi
          livenessProbe:
            httpGet:
              path: /v1/plugins
              port: 21413
            initialDelaySeconds: 5
            timeoutSeconds: 5
          readinessProbe:
            httpGet:
              path: /v1/plugins
              port: 21413
            initialDelaySeconds: 5
            timeoutSeconds: 5
      volumes:
        - name: task-logs-k8s-events
          configMap:
            name: task-autoload
            items:
              - key: task-logs-k8s-events.yaml 
                path: task-logs-k8s-events.yaml
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
