---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: forwarder-ovs
  labels:
    app: forwarder-ovs
spec:
  selector:
    matchLabels:
      app: forwarder-ovs
  template:
    metadata:
      labels:
        app: forwarder-ovs
        "spiffe.io/spiffe-id": "true"
    spec:
      hostPID: true
      hostNetwork: true
      containers:
        - image: ghcr.io/networkservicemesh/ci/cmd-forwarder-ovs-use-host-ovs:7aca11b
          imagePullPolicy: IfNotPresent
          name: forwarder-ovs
          securityContext:
            privileged: true
          env:
            - name: NSM_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: SPIFFE_ENDPOINT_SOCKET
              value: unix:///run/spire/sockets/agent.sock
            - name: NSM_CONNECT_TO
              value: unix:///var/lib/networkservicemesh/nsm.io.sock
            - name: NSM_LOG_LEVEL
              value: TRACE
            - name: NSM_SRIOV_CONFIG_FILE
              value: /var/lib/networkservicemesh/smartnic.config
            - name: NSM_BRIDGE_NAME
              value: br-nsm
            - name: NSM_TUNNEL_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
          volumeMounts:
            - name: spire-agent-socket
              mountPath: /run/spire/sockets
              readOnly: true
            - name: nsm
              mountPath: /var/lib/networkservicemesh
            - name: kubelet-socket
              mountPath: /var/lib/kubelet
            - name: cgroup
              mountPath: /host/sys/fs/cgroup
            - name: vfio
              mountPath: /host/dev/vfio
            - name: ovs-socket
              mountPath: /var/run/openvswitch
              readOnly: true
          resources:
            limits:
              memory: 1Gi
              cpu: 2
      volumes:
        - name: spire-agent-socket
          hostPath:
            path: /run/spire/sockets
            type: Directory
        - name: nsm
          hostPath:
            path: /var/lib/networkservicemesh
            type: Directory
        - name: kubelet-socket
          hostPath:
            path: /var/lib/kubelet
            type: Directory
        - name: cgroup
          hostPath:
            path: /sys/fs/cgroup
            type: Directory
        - name: vfio
          hostPath:
            path: /dev/vfio
            type: DirectoryOrCreate
        - name: ovs-socket
          hostPath:
             path: /var/run/openvswitch
             type: DirectoryOrCreate
