---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: forwarder-generic
  labels:
    app: forwarder-generic
spec:
  selector:
    matchLabels:
      app: forwarder-generic
  template:
    metadata:
      labels:
        app: forwarder-generic
    spec:
      hostNetwork: true
      containers:
        - image: registry.nordix.org/cloud-native/nsm/forwarder-generic:latest
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          name: forwarder-generic
          env:
            - name: SPIFFE_ENDPOINT_SOCKET
              value: unix:///run/spire/sockets/agent.sock
            - name: NSM_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: NSM_CONNECT_TO
              value: "unix:///var/lib/networkservicemesh/nsm.io.sock"
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: CALLOUT
              value: "/bin/forwarder.sh"
            - name: INTERFACE
              value: "eth1"
            - name: NSM_LABELS
              value: forwarder:forwarder-generic
          volumeMounts:
            - name: spire-agent-socket
              mountPath: /run/spire/sockets
              readOnly: true
            - name: nsm-socket
              mountPath: /var/lib/networkservicemesh
      volumes:
        - name: spire-agent-socket
          hostPath:
            path: /run/spire/sockets
            type: Directory
        - name: nsm-socket
          hostPath:
            path: /var/lib/networkservicemesh
            type: DirectoryOrCreate
