diff --git a/deployment/helm/node-feature-discovery/templates/nodefeaturerules.yaml b/deployment/helm/node-feature-discovery/templates/nodefeaturerules.yaml new file mode 100644 index 0000000000..d17a240615 --- /dev/null +++ b/deployment/helm/node-feature-discovery/templates/nodefeaturerules.yaml @@ -0,0 +1,36 @@ +{{- if .Values.nodefeaturerules }} +apiVersion: nfd.k8s-sigs.io/v1alpha1 +kind: NodeFeatureRule +metadata: + name: npu +spec: + rules: + - name: "ascend/atlas-800t-a2-arm" + labels: + "node-role.kubernetes.io/worker": "worker" + "workerselector": "dls-worker-node" + "host-arch": "huawei-arm" + "accelerator": "huawei-Ascend910" + matchFeatures: + - feature: pci.device + matchExpressions: + vendor: {op: In, value: ["19e5"]} + device: {op: In, value: ["d802"]} + - feature: kernel.config + matchExpressions: + X86: {op: In, value: ["n"]} + - name: "ascend/atlas-800t-a2-x86" + labels: + "node-role.kubernetes.io/worker": "worker" + "workerselector": "dls-worker-node" + "host-arch": "huawei-x86" + "accelerator": "huawei-Ascend910" + matchFeatures: + - feature: pci.device + matchExpressions: + vendor: {op: In, value: ["19e5"]} + device: {op: In, value: ["d802"]} + - feature: kernel.config + matchExpressions: + X86: {op: In, value: ["y"]} +{{- end }} \ No newline at end of file diff --git a/deployment/helm/node-feature-discovery/values.yaml b/deployment/helm/node-feature-discovery/values.yaml index 2291aef4fc..7742bd7d88 100644 --- a/deployment/helm/node-feature-discovery/values.yaml +++ b/deployment/helm/node-feature-discovery/values.yaml @@ -511,3 +511,5 @@ tls: prometheus: enable: false labels: {} + +nodefeaturerules: true \ No newline at end of file diff --git a/pkg/nfd-master/nfd-master.go b/pkg/nfd-master/nfd-master.go index 73e8666734..80c748fe6c 100644 --- a/pkg/nfd-master/nfd-master.go +++ b/pkg/nfd-master/nfd-master.go @@ -1278,12 +1278,29 @@ func (m *nfdMaster) configure(filepath string, overrides string) error { // addNs adds a namespace if one isn't already found from src string func addNs(src string, nsToAdd string) string { - if strings.Contains(src, "/") { + if strings.Contains(src, "/") || containsHW(src) { return src } return path.Join(nsToAdd, src) } +// containsHW returns true if the label contains Huawei's keys +func containsHW(src string) bool { + keys := []string{ + "workerselector", + "host-arch", + "accelerator", + "accelerator-type", + "servertype", + } + for _, key := range keys { + if key == src { + return true + } + } + return false +} + // splitNs splits a name into its namespace and name parts func splitNs(fullname string) (string, string) { split := strings.SplitN(fullname, "/", 2)