# Copyright (C) 2021  Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: wla-daemonset
  namespace: isecl
  labels:
    app: wla
spec:
  selector:
    matchLabels:
      app: wla
  template:
    metadata:
      labels:
        app: wla
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: node.type
                    operator: In
                    values:
                      - "TXT-ENABLED"
                      - "SUEFI-ENABLED"
      containers:
        - image: <image-name>:<image-tag>
          name: wla
          securityContext:
            privileged: true
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: wla-config
          volumeMounts:
            - name: wla-logs-volume
              mountPath: /var/log/workload-agent/
            - name: wla-config-volume
              mountPath: /etc/workload-agent/
            - mountPath: /dev/tpmrm0
              name: tpmrm
            - name: ta-config-volume
              mountPath: /opt/trustagent/configuration
            - name: wla-socket
              mountPath: /var/run/workload-agent
            - mountPath: /etc/secrets/
              name: wla-secrets
              readOnly: true
      volumes:
        - name: wla-logs-volume
          hostPath:
            path: /var/log/workload-agent
            type: DirectoryOrCreate
        - name: wla-config-volume
          hostPath:
            path: /etc/workload-agent/
            type: DirectoryOrCreate
        - name: tpmrm
          hostPath:
            path: /dev/tpmrm0
        - name: ta-config-volume
          hostPath:
            path: /opt/trustagent/configuration
            type: DirectoryOrCreate
        - name: wla-socket
          hostPath:
            path: /var/run/workload-agent
            type: DirectoryOrCreate
        - name: wla-secrets
          projected:
            sources:
              - secret:
                  name: wla-credentials
              - secret:
                  name: bearer-token