From 2a56d18fda98815696a6493876202f03149c7834 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Thu, 8 Apr 2021 14:45:27 -0500 Subject: [PATCH] Add support for Core-Config Operand NFD Patch kubernetes-sigs/node-feature-discovery#433 changed the way nfd-worker get's arguments, this patch looks to update the operator to the new way of running the nfd-worker Signed-off-by: Carlos Eduardo Arango Gutierrez --- api/v1/nodefeaturediscovery_types.go | 8 +- api/v1/zz_generated.deepcopy.go | 8 +- build/assets/worker/04_worker_cm.yaml | 106 +++++++++++++++++- build/assets/worker/05_worker_ds.yaml | 6 +- ....kubernetes.io_nodefeaturediscoveries.yaml | 2 +- ...kubernetes.io_v1_nodefeaturediscovery.yaml | 21 +++- 6 files changed, 136 insertions(+), 15 deletions(-) diff --git a/api/v1/nodefeaturediscovery_types.go b/api/v1/nodefeaturediscovery_types.go index 8bcf2bc0..a516bd6a 100644 --- a/api/v1/nodefeaturediscovery_types.go +++ b/api/v1/nodefeaturediscovery_types.go @@ -26,7 +26,7 @@ import ( // +k8s:openapi-gen=true type NodeFeatureDiscoverySpec struct { Operand OperandSpec `json:"operand"` - WorkerConfig ConfigSpec `json:"workerConfig"` + WorkerConfig ConfigMap `json:"workerConfig"` } // OperandSpec describes configuration options for the operand @@ -42,8 +42,8 @@ type OperandSpec struct { ImagePullPolicy string `json:"imagePullPolicy,omitempty"` } -// ConfigSpec describes configuration options for the NFD worker -type ConfigSpec struct { +// ConfigMap describes configuration options for the NFD worker +type ConfigMap struct { // BinaryData holds the NFD configuration file ConfigData string `json:"configData"` } @@ -100,6 +100,6 @@ func (o *OperandSpec) ImagePolicy(pullPolicy string) corev1.PullPolicy { } // Data returns a valid ConfigMap name -func (c *ConfigSpec) Data() string { +func (c *ConfigMap) Data() string { return c.ConfigData } diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 15083330..033b8599 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -26,16 +26,16 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) { +func (in *ConfigMap) DeepCopyInto(out *ConfigMap) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigSpec. -func (in *ConfigSpec) DeepCopy() *ConfigSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMap. +func (in *ConfigMap) DeepCopy() *ConfigMap { if in == nil { return nil } - out := new(ConfigSpec) + out := new(ConfigMap) in.DeepCopyInto(out) return out } diff --git a/build/assets/worker/04_worker_cm.yaml b/build/assets/worker/04_worker_cm.yaml index 63ae031e..8bc45794 100644 --- a/build/assets/worker/04_worker_cm.yaml +++ b/build/assets/worker/04_worker_cm.yaml @@ -5,7 +5,61 @@ metadata: data: nfd-worker-conf: | #uncomment to configure + #core: + # labelWhiteList: + # noPublish: false + # sleepInterval: 60s + # sources: [all] + # klog: + # addDirHeader: false + # alsologtostderr: false + # logBacktraceAt: + # logtostderr: true + # skipHeaders: false + # stderrthreshold: 2 + # v: 0 + # vmodule: + ## NOTE: the following options are not dynamically run-time configurable + ## and require a nfd-worker restart to take effect after being changed + # logDir: + # logFile: + # logFileMaxSize: 1800 + # skipLogHeaders: false #sources: + # cpu: + # cpuid: + ## NOTE: whitelist has priority over blacklist + # attributeBlacklist: + # - "BMI1" + # - "BMI2" + # - "CLMUL" + # - "CMOV" + # - "CX16" + # - "ERMS" + # - "F16C" + # - "HTT" + # - "LZCNT" + # - "MMX" + # - "MMXEXT" + # - "NX" + # - "POPCNT" + # - "RDRAND" + # - "RDSEED" + # - "RDTSCP" + # - "SGX" + # - "SSE" + # - "SSE2" + # - "SSE3" + # - "SSE4.1" + # - "SSE4.2" + # - "SSSE3" + # attributeWhitelist: + # kernel: + # kconfigFile: "/path/to/kconfig" + # configOpts: + # - "NO_HZ" + # - "X86" + # - "DMI" # pci: # deviceClassWhitelist: # - "0200" @@ -17,4 +71,54 @@ data: # - "device" # - "subsystem_vendor" # - "subsystem_device" - + # usb: + # deviceClassWhitelist: + # - "0e" + # - "ef" + # - "fe" + # - "ff" + # deviceLabelFields: + # - "class" + # - "vendor" + # - "device" + # custom: + # - name: "my.kernel.feature" + # matchOn: + # - loadedKMod: ["example_kmod1", "example_kmod2"] + # - name: "my.pci.feature" + # matchOn: + # - pciId: + # class: ["0200"] + # vendor: ["15b3"] + # device: ["1014", "1017"] + # - pciId : + # vendor: ["8086"] + # device: ["1000", "1100"] + # - name: "my.usb.feature" + # matchOn: + # - usbId: + # class: ["ff"] + # vendor: ["03e7"] + # device: ["2485"] + # - usbId: + # class: ["fe"] + # vendor: ["1a6e"] + # device: ["089a"] + # - name: "my.combined.feature" + # matchOn: + # - pciId: + # vendor: ["15b3"] + # device: ["1014", "1017"] + # loadedKMod : ["vendor_kmod1", "vendor_kmod2"] + # - name: "feature.by.nodename" + # value: customValue + # matchOn: + # - nodename: ["worker-0", "my-.*-node"] + custom-conf: | + # - name: "more.kernel.features" + # matchOn: + # - loadedKMod: ["example_kmod3"] + # - name: "more.features.by.nodename" + # value: customValue + # matchOn: + # - nodename: ["special-.*-node-.*"] diff --git a/build/assets/worker/05_worker_ds.yaml b/build/assets/worker/05_worker_ds.yaml index 3b4afcd6..4c79f0bc 100644 --- a/build/assets/worker/05_worker_ds.yaml +++ b/build/assets/worker/05_worker_ds.yaml @@ -40,7 +40,6 @@ spec: command: - "nfd-worker" args: - - "--sleep-interval=60s" - "--server=nfd-master:$(NFD_MASTER_SERVICE_PORT)" volumeMounts: - name: host-boot @@ -51,7 +50,7 @@ spec: readOnly: true - name: host-sys mountPath: "/host-sys" - - name: config + - name: nfd-worker-config mountPath: "/etc/kubernetes/node-feature-discovery" - name: nfd-hooks mountPath: "/etc/kubernetes/node-feature-discovery/source.d" @@ -78,10 +77,9 @@ spec: - name: nfd-features hostPath: path: "/etc/kubernetes/node-feature-discovery/features.d" - - name: config + - name: nfd-worker-config configMap: name: nfd-worker items: - key: nfd-worker-conf path: nfd-worker.conf - diff --git a/config/crd/bases/nfd.kubernetes.io_nodefeaturediscoveries.yaml b/config/crd/bases/nfd.kubernetes.io_nodefeaturediscoveries.yaml index c70c22f6..0a035c65 100644 --- a/config/crd/bases/nfd.kubernetes.io_nodefeaturediscoveries.yaml +++ b/config/crd/bases/nfd.kubernetes.io_nodefeaturediscoveries.yaml @@ -52,7 +52,7 @@ spec: type: string type: object workerConfig: - description: ConfigSpec describes configuration options for the NFD + description: ConfigMap describes configuration options for the NFD worker properties: configData: diff --git a/config/samples/nfd.kubernetes.io_v1_nodefeaturediscovery.yaml b/config/samples/nfd.kubernetes.io_v1_nodefeaturediscovery.yaml index 76cf2154..aea5d411 100644 --- a/config/samples/nfd.kubernetes.io_v1_nodefeaturediscovery.yaml +++ b/config/samples/nfd.kubernetes.io_v1_nodefeaturediscovery.yaml @@ -10,6 +10,26 @@ spec: imagePullPolicy: Always workerConfig: configData: | + #core: + # labelWhiteList: + # noPublish: false + # sleepInterval: 60s + # sources: [all] + # klog: + # addDirHeader: false + # alsologtostderr: false + # logBacktraceAt: + # logtostderr: true + # skipHeaders: false + # stderrthreshold: 2 + # v: 0 + # vmodule: + ## NOTE: the following options are not dynamically run-time configurable + ## and require a nfd-worker restart to take effect after being changed + # logDir: + # logFile: + # logFileMaxSize: 1800 + # skipLogHeaders: false #sources: # cpu: # cpuid: @@ -95,4 +115,3 @@ spec: # vendor: ["15b3"] # device: ["1014", "1017"] # loadedKMod : ["vendor_kmod1", "vendor_kmod2"] -