Skip to content

Skip Huawei labels when NFD patches a default namespace #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v0.14.2-es
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node-role.kubernetes.io/worker=worker
workerselector=dls-worker-node
host-arch=huawei-arm或host-arch=huawei-x86
accelerator=huawei-Ascend910
需要以上四个标签

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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 }}
2 changes: 2 additions & 0 deletions deployment/helm/node-feature-discovery/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,5 @@ tls:
prometheus:
enable: false
labels: {}

nodefeaturerules: true
19 changes: 18 additions & 1 deletion pkg/nfd-master/nfd-master.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down