# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2020-2021 Intel Corporation

apiVersion: v1
kind: ConfigMap
metadata:
  name: daemon-config
  namespace: default
immutable: false
data:
  namespace: |
    apiVersion: v1
    kind: Namespace
    metadata:
      name: vran-acceleration-operators
  serviceAccount: |
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: accelerator-discovery
      namespace: vran-acceleration-operators
  clusterRole: |
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: accelerator-discovery
    rules:
    - apiGroups: [""]
      resources: ["nodes"]
      verbs: ["get", "update"]
  clusterRoleBinding: |
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: accelerator-discovery
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: accelerator-discovery
      namespace: vran-acceleration-operators
    subjects:
    - kind: ServiceAccount
      name: accelerator-discovery
      namespace: vran-acceleration-operators
    userNames:
    - system:serviceaccount:vran-acceleration-operators:accelerator-discovery
  configMap: |
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: n3000-labeler-config
      namespace: vran-acceleration-operators
    data:
      accelerators.json: |
        {
          "VendorID": "8086",
          "Class": "12",
          "SubClass": "00",
          "Devices": {
            "0d8f": "FPGA_5GNR",
            "5052": "FPGA_LTE",
            "0b32": ""
          },
          "NodeLabel": "fpga.intel.com/intel-accelerator-present"
        }
  daemonSet: |
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      labels:
        app: accelerator-discovery
      name: accelerator-discovery
      namespace: vran-acceleration-operators
    spec:
      minReadySeconds: 10
      selector:
        matchLabels:
          app: accelerator-discovery
      template:
        metadata:
          labels:
            app: accelerator-discovery
          name: accelerator-discovery
        spec:
          serviceAccount: accelerator-discovery
          serviceAccountName: accelerator-discovery
          containers:
          - image: "N3000_LABELER_IMAGE-123"
            name: accelerator-discovery
            securityContext:
              readOnlyRootFilesystem: true
            volumeMounts:
            - name: config-volume
              mountPath: "/labeler-workspace/config"
              readOnly: true
            env:
              - name: NODENAME
                valueFrom:
                  fieldRef:
                    fieldPath: spec.nodeName
          volumes:
            - name: config-volume
              configMap:
                name: n3000-labeler-config
                items:
                - key: accelerators.json
                  path: accelerators.json
