Skip to content

Commit 49886ed

Browse files
committed
Add sample NodeFeatureRules for all built-in labels
This patch adds sample NodeFeatureRules that correspond the built-in labels created by nfd-worker (with its default configuration). The samples provide examples on how to utilize NodeFeatureRules and an easy way to modify the labels being generated. In order to replace the built-in node labeling of nfd-worker with these sample rules, all node labeling from nfd-worker must be disabled by setting the "core.labelSources" configuration option to an empty list (or specify "-label-sources= " on the command line). Then, with all nfd-worker side labeling disabled, just apply the rules with kubectl apply -f samples/
1 parent 912c7dc commit 49886ed

10 files changed

+350
-0
lines changed

samples/nodefeaturerule-cpu.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in cpu feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-cpu-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in cpu-cpuid labels"
11+
labelsTemplate: |
12+
{{ range .cpu.cpuid }}cpu-cpuid.{{ .Name }}=true
13+
{{ end }}
14+
matchFeatures:
15+
- feature: cpu.cpuid
16+
matchName:
17+
op: NotIn
18+
value:
19+
- "BMI1"
20+
- "BMI2"
21+
- "CLMUL"
22+
- "CMOV"
23+
- "CX16"
24+
- "ERMS"
25+
- "F16C"
26+
- "HTT"
27+
- "LZCNT"
28+
- "MMX"
29+
- "MMXEXT"
30+
- "NX"
31+
- "POPCNT"
32+
- "RDRAND"
33+
- "RDSEED"
34+
- "RDTSCP"
35+
- "SGX"
36+
- "SGXLC"
37+
- "SSE"
38+
- "SSE2"
39+
- "SSE3"
40+
- "SSE4"
41+
- "SSE42"
42+
- "SSSE3"
43+
44+
- name: "nfd built-in cpu-hardware_multithreading label"
45+
labelsTemplate: |
46+
{{ range .cpu.topology }}cpu-{{ .Name }}={{ .Value }}
47+
{{ end }}
48+
matchFeatures:
49+
- feature: cpu.topology
50+
matchName:
51+
op: In
52+
value:
53+
- "hardware_multithreading"
54+
55+
- name: "nfd built-in cpu-cstate and cpu-pstate labels"
56+
labelsTemplate: |
57+
{{ range .cpu.cstate }}cpu-cstate.{{ .Name }}={{ .Value }}
58+
{{ end }}
59+
{{ range .cpu.pstate }}cpu-pstate.{{ .Name }}={{ .Value }}
60+
{{ end }}
61+
matchAny:
62+
- matchFeatures:
63+
- feature: cpu.cstate
64+
matchName:
65+
op: Exists
66+
- matchFeatures:
67+
- feature: cpu.pstate
68+
matchName:
69+
op: Exists
70+
71+
- name: "nfd built-in cpu-model labels"
72+
labelsTemplate: |
73+
{{ range .cpu.model }}cpu-model.{{ .Name }}={{ .Value }}
74+
{{ end }}
75+
matchFeatures:
76+
- feature: cpu.model
77+
matchName:
78+
op: Exists
79+
80+
- name: "nfd built-in cpu-security labels"
81+
labelsTemplate: |
82+
{{ range .cpu.security }}cpu-security.{{ .Name }}={{ .Value }}
83+
{{ end }}
84+
matchFeatures:
85+
- feature: cpu.security
86+
matchName:
87+
op: NotIn
88+
value:
89+
- "tdx.total_keys"
90+
- "sgx.epc"
91+
- "sev.encrypted_state_ids"
92+
- "sev.asids"
93+
94+
- name: "nfd built-in cpu-sst labels"
95+
labelsTemplate: |
96+
{{ range .cpu.sst }}cpu-power.sst_{{ .Name }}={{ .Value }}
97+
{{ end }}
98+
matchFeatures:
99+
- feature: cpu.sst
100+
matchName:
101+
op: Exists
102+
103+
- name: "nfd built-in cpu-coprocessor labels"
104+
labelsTemplate: |
105+
{{ range .cpu.sst }}cpu-coprocessor.{{ .Name }}={{ .Value }}
106+
{{ end }}
107+
matchFeatures:
108+
- feature: cpu.coprocessor
109+
matchName:
110+
op: In
111+
value:
112+
- "nx_gzip"

samples/nodefeaturerule-custom.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in static custom feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-custom-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in static custom rdma.capable label"
11+
labels:
12+
"custom-rdma.capable": "true"
13+
matchFeatures:
14+
- feature: pci.device
15+
matchExpressions:
16+
vendor:
17+
op: In
18+
value: ["15b3"]
19+
20+
- name: "nfd built-in static custom rdma.available label"
21+
labels:
22+
"custom-rdma.available": "true"
23+
matchFeatures:
24+
- feature: kernel.loadedmodule
25+
matchExpressions:
26+
"ib_uverbs":
27+
op: Exists
28+
"rdma_ucm":
29+
op: Exists

samples/nodefeaturerule-kernel.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in kernel feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-kernel-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in kernel-version labels"
11+
labelsTemplate: |
12+
{{ range .kernel.version }}kernel-version.{{ .Name }}={{ .Value }}
13+
{{ end }}
14+
matchFeatures:
15+
- feature: kernel.version
16+
matchName:
17+
op: Exists
18+
19+
- name: "nfd built-in kernel-config labels"
20+
labelsTemplate: |
21+
{{ range .kernel.config }}kernel-config.{{ .Name }}=true
22+
{{ end }}
23+
matchFeatures:
24+
- feature: kernel.config
25+
matchExpressions:
26+
"NO_HZ": {op: In, value: ["y"]}
27+
"NO_HZ_IDLE": {op: In, value: ["y"]}
28+
"NO_HZ_FULL": {op: In, value: ["y"]}
29+
"PREEMPT": {op: In, value: ["y"]}
30+
31+
- name: "nfd built-in kernel-selinux labels"
32+
labels:
33+
"kernel-selinux.enabled": "true"
34+
matchFeatures:
35+
- feature: kernel.selinux
36+
matchExpressions:
37+
"enabled":
38+
op: IsTrue

samples/nodefeaturerule-local.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in local feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-local-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in labels from the local feature source"
11+
labelsTemplate: |
12+
{{ range .local.label }}{{ .Name }}={{ .Value }}
13+
{{ end }}
14+
matchFeatures:
15+
- feature: local.label
16+
matchName:
17+
op: Exists

samples/nodefeaturerule-memory.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in memory feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-memory-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in memory-numa labels"
11+
labels:
12+
"memory-numa": "true"
13+
matchFeatures:
14+
- feature: memory.numa
15+
matchExpressions:
16+
"is_numa":
17+
op: IsTrue
18+
19+
- name: "nfd built-in memory-nv.present label"
20+
labelsTemplate: "{{ if gt (len .memory.nv ) 0 }}memory-nv.present=true{{ end }}"
21+
matchFeatures:
22+
- feature: memory.nv
23+
matchName:
24+
op: Exists
25+
26+
- name: "nfd built-in memory-nv.dax label"
27+
labels:
28+
"memory.nv.dax": "true"
29+
matchFeatures:
30+
- feature: memory.nv
31+
matchExpressions:
32+
"devtype":
33+
op: In
34+
value: ["nd_dax"]

samples/nodefeaturerule-network.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in networkfeature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-network-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in network-sriov.capable label"
11+
labels:
12+
"network-sriov.capable": "true"
13+
matchFeatures:
14+
- feature: network.device
15+
matchExpressions:
16+
"sriov_totalvfs":
17+
op: Gt
18+
value: ["0"]
19+
20+
- name: "nfd built-in network-sriov.configured label"
21+
labels:
22+
"network-sriov.configured": "true"
23+
matchFeatures:
24+
- feature: network.device
25+
matchExpressions:
26+
"network-sriov_numvfs":
27+
op: Gt
28+
value: ["0"]

samples/nodefeaturerule-pci.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in pci feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-pci-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in pci-<device>.present labels"
11+
labelsTemplate: |
12+
{{ range .pci.device }}pci-{{ .class }}_{{ .vendor }}.present=true
13+
{{ end }}
14+
matchFeatures:
15+
- feature: pci.device
16+
matchExpressions:
17+
"class":
18+
op: InRegexp
19+
value: ["^03", "^0b40", "^12"]
20+
21+
- name: "nfd built-in pci-<device>.sriov.capable labels"
22+
labelsTemplate: |
23+
{{ range .pci.device }}pci-{{ .class }}_{{ .vendor }}.sriov.capable=true
24+
{{ end }}
25+
matchFeatures:
26+
- feature: pci.device
27+
matchExpressions:
28+
"class":
29+
op: InRegexp
30+
value: ["^03", "^0b40", "^12"]
31+
"sriov_totalvfs":
32+
op: Exists

samples/nodefeaturerule-storage.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in storage feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-storage-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in storage-nonrotationaldisk label"
11+
labels:
12+
"storage-nonrotationaldisk": "true"
13+
matchFeatures:
14+
- feature: storage.block
15+
matchExpressions:
16+
"rotational":
17+
op: In
18+
value: ["0"]

samples/nodefeaturerule-system.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in system feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-system-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in system-os_release labels"
11+
labelsTemplate: |
12+
{{ range .system.osrelease }}system-os_release.{{ .Name }}={{ .Value }}
13+
{{ end }}
14+
matchFeatures:
15+
- feature: system.osrelease
16+
matchName:
17+
op: In
18+
value:
19+
- "ID"
20+
- "VERSION_ID"
21+
- "VERSION_ID.major"
22+
- "VERSION_ID.minor"
23+

samples/nodefeaturerule-usb.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# This NodeFeatureRule replicates all built-in usb feature labels of NFD.
3+
#
4+
apiVersion: nfd.k8s-sigs.io/v1alpha1
5+
kind: NodeFeatureRule
6+
metadata:
7+
name: nfd-builtin-usb-features
8+
spec:
9+
rules:
10+
- name: "nfd built-in usb-<device>.present labels"
11+
labelsTemplate: |
12+
{{ range .usb.device }}usb-{{ .class }}_{{ .vendor }}_{{ .device }}.present=true
13+
{{ end }}
14+
matchFeatures:
15+
- feature: usb.device
16+
matchExpressions:
17+
"class":
18+
op: In
19+
value: ["0e", "ef", "fe", "ff"]

0 commit comments

Comments
 (0)