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

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: sagent-daemonset
  namespace: isecl
  labels:
    env: test
    app: sagent
spec: 
  selector:
    matchLabels:
      app: sagent
  template:
    metadata:
      labels:
        app: sagent
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: node.type
                    operator: In
                    values:
                      - "SGX-ENABLED"
      securityContext:
        fsGroup: 1001
      containers:
        - name: sagent
          image: <image-name>:<image-tag>
          imagePullPolicy: Always
          securityContext:
            privileged: true
          envFrom:
            - configMapRef:
                name: sagent-config
          volumeMounts:
            - name: sagent-config-volume
              mountPath: /etc/sgx_agent/
            - name: sagent-logs-volume
              mountPath: /var/log/sgx_agent/
            - name: sagent-efi-volume
              mountPath: /sys/firmware/efi/efivars
            - name: sagent-hostname-path
              mountPath: /etc/hostname
            - name: sagent-sgx-device
              mountPath: /dev/sgx/
            - name: sagent-pck-data
              mountPath: /opt/pckData
            - mountPath: /etc/secrets/
              name: sagent-secrets
              readOnly: true
      volumes:
        - name: sagent-logs-volume
          hostPath:
            path: /var/log/sgx_agent/
            type: DirectoryOrCreate
        - name: sagent-config-volume
          hostPath:
            path: /etc/sgx_agent/
            type: DirectoryOrCreate
        - name: sagent-efi-volume
          hostPath:
            path: /sys/firmware/efi/efivars
            type: DirectoryOrCreate
        - name: sagent-hostname-path
          hostPath:
            path: /etc/hostname
            type: File
        - name: sagent-sgx-device
          hostPath:
            path: /dev/sgx/
            type: DirectoryOrCreate
        - name: sagent-pck-data
          hostPath:
            path: /opt/pckData
            type: FileOrCreate
        - name: sagent-secrets
          secret:
              secretName: sagent-credentials