---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: swisnap-agent-k8s
  labels:
    app: swisnap-agent-k8s
spec:
  replicas: 1
  selector:
    matchLabels:
      app: swisnap-agent-k8s
  template:
    metadata:
      labels:
        app: swisnap-agent-k8s
    spec:
      serviceAccountName: swisnap-agent-serviceaccount
      containers:
        - name: swisnap-agent-k8s
          image: solarwinds/solarwinds-snap-agent-docker:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 21413
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /v1/plugins
              port: 21413
            initialDelaySeconds: 10
            timeoutSeconds: 5
          readinessProbe:
            httpGet:
              path: /v1/plugins
              port: 21413
            initialDelaySeconds: 10
            timeoutSeconds: 5
          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-k8s-configmap
          volumeMounts:
            - name: proc
              mountPath: /host/proc
              readOnly: true
          resources:
            limits:
              cpu: 200m
              memory: 512Mi
            requests:
              cpu: 100m
              memory: 256Mi
      volumes:
        - name: proc
          hostPath:
            path: /proc
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
