### Install NFD from Source Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/helm.md Clone the repository and install the chart directly from the local filesystem for development versions. ```bash git clone https://github.com/kubernetes-sigs/node-feature-discovery/ cd node-feature-discovery/deployment/helm helm install nfd ./node-feature-discovery/ --namespace node-feature-discovery --create-namespace ``` -------------------------------- ### MatchName Example for CPUID Features Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md An example demonstrating how to use matchName with the InRegexp operator to match CPUID features starting with 'AVX'. This is useful for selecting specific CPU instruction sets. ```yaml matchFeatures: - feature: cpu.cpuid matchName: {op: InRegexp, value: ["^AVX"]} ``` -------------------------------- ### Install Kubectl NFD Plugin Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/kubectl-plugin.md Installs the kubectl nfd plugin by cloning the repository, building the binary, and moving it to the desired location. ```bash git clone https://github.com/kubernetes-sigs/node-feature-discovery cd node-feature-discovery make build-kubectl-nfd KUBECTL_PATH=/usr/local/bin/ mv ./bin/kubectl-nfd ${KUBECTL_PATH} ``` -------------------------------- ### Install NFD using OCI Helm Repository Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/deployment/helm/node-feature-discovery/README.md Installs NFD with default configuration using the OCI Helm repository. Ensure you have Helm v3+ installed. ```bash helm install nfd --namespace node-feature-discovery --create-namespace oci://gcr.io/k8s-staging-nfd/charts/node-feature-discovery --version 0.0.0-master ``` -------------------------------- ### Install NFD via OCI Helm Repository Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/helm.md Use the OCI-compliant repository to install NFD with default configuration. ```bash helm install nfd --namespace node-feature-discovery --create-namespace {{ site.helm_oci_repo }} --version {{ site.helm_chart_version }} ``` -------------------------------- ### Install NFD with Kustomize Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/get-started/quick-start.md Deploys NFD using the default overlay via kubectl. ```bash kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref={{ site.release }}" ``` -------------------------------- ### Install NFD via Legacy Helm Repository Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/helm.md Add and install from the legacy HTTP repository. This method is deprecated in favor of OCI. ```bash helm repo add nfd https://kubernetes-sigs.github.io/node-feature-discovery/charts helm repo update helm install nfd nfd/node-feature-discovery --namespace node-feature-discovery --create-namespace ``` -------------------------------- ### Install NFD with Specific Helm Parameters Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/deployment/helm/node-feature-discovery/README.md Installs NFD using the OCI Helm repository, specifying individual parameters like nameOverride and replicaCount directly in the command. ```bash helm install --set nameOverride=NFDinstance --set master.replicaCount=2 --namespace nfd --create-namespace nfd oci://gcr.io/k8s-staging-nfd/charts/node-feature-discovery --version 0.0.0-master ``` -------------------------------- ### Install Node Feature Discovery with Helm Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/README.md Use Helm to install Node Feature Discovery. Ensure the correct namespace and chart version are specified. ```bash helm install -n node-feature-discovery --create-namespace nfd oci://registry.k8s.io/nfd/charts/node-feature-discovery --version 0.18.3 ``` -------------------------------- ### DryRun NodeFeatureRule with Example Files Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/kubectl-plugin.md Executes a dry run using example NodeFeatureRule and NodeFeature files. This demonstrates the output of rule evaluation. ```bash $ kubectl nfd dryrun -f examples/nodefeaturerule.yaml -n examples/nodefeature.yaml Evaluating NodeFeatureRule "examples/nodefeaturerule.yaml" against NodeFeature "examples/nodefeature.yaml" Processing rule: my sample rule *** Labels *** vendor.io/my-sample-feature=true NodeFeatureRule "examples/nodefeaturerule.yaml" is valid for NodeFeature "examples/nodefeature.yaml" ``` -------------------------------- ### Install NFD using Helm Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/get-started/index.md Install Node Feature Discovery using Helm. Ensure you have Helm installed and configured for your Kubernetes cluster. ```bash helm install -n node-feature-discovery --create-namespace nfd {{ site.helm_oci_repo }} --version {{ site.helm_chart_version }} ``` -------------------------------- ### Install NFD with Custom Values File Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/deployment/helm/node-feature-discovery/README.md Installs NFD using the OCI Helm repository, overriding default values with a custom values file. Specify the path to your custom values file. ```bash helm install -f --namespace nfd --create-namespace nfd oci://gcr.io/k8s-staging-nfd/charts/node-feature-discovery --version 0.0.0-master ``` -------------------------------- ### Install NFD Deployment with Helm Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/helm.md Use this command to upgrade or install the NFD deployment using Helm. Ensure the HELM_INSTALL_NAME and NFD_NS environment variables are set. ```bash helm upgrade $HELM_INSTALL_NAME {{ site.helm_oci_repo }} --version {{ site.helm_chart_version }} --namespace $NFD_NS ``` -------------------------------- ### Install Node Feature Discovery and Prometheus Metrics Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/kustomize.md Run these commands to apply the default NFD overlay and the Prometheus overlay for metrics scraping. Ensure you replace '{{ site.release }}' with the appropriate release tag. ```bash kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref={{ site.release }}" kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/prometheus?ref={{ site.release }}" ``` -------------------------------- ### Install NFD Operator Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/operator.md Use this command to install the NFD operator from operatorhub.io. Ensure OLM is installed beforehand. ```bash kubectl create -f https://operatorhub.io/install/nfd-operator.yaml ``` -------------------------------- ### Install NFD using Helm Chart Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/deployment/helm/node-feature-discovery/README.md Use these commands to install or upgrade the NFD Helm chart and apply necessary CRDs. Ensure the NFD namespace is set and the Helm release name is defined. ```bash export NFD_NS=node-feature-discovery export HELM_INSTALL_NAME=nfd # Install and upgrade CRD's kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/deployment/base/nfd-crds/nfd-api-crds.yaml # Install the new NFD deployment helm upgrade $HELM_INSTALL_NAME oci://gcr.io/k8s-staging-nfd/charts/node-feature-discovery --version 0.0.0-master --namespace $NFD_NS ``` -------------------------------- ### OCI Artifact Manifest Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/image-compatibility.md Example of an OCI artifact manifest used to store image compatibility metadata. ```APIDOC ## OCI Artifact Manifest ### Description An OCI artifact manifest storing image compatibility metadata. ### Example ```json { "schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", "artifactType": "application/vnd.nfd.image-compatibility.v1alpha1", "config": { "mediaType": "application/vnd.oci.empty.v1+json", "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a", "size": 2 }, "layers": [ { "mediaType": "application/vnd.nfd.image-compatibility.spec.v1alpha1+yaml", "digest": "sha256:4a47f8ae4c713906618413cb9795824d09eeadf948729e213a1ba11a1e31d052", "size": 1710 } ], "subject": { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270", "size": 7682 }, "annotations": { "oci.opencontainers.image.created": "2024-03-27T08:08:08Z" } } ``` ``` -------------------------------- ### Start NFD Development Environment with Tilt Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Run this command in the root of your NFD codebase to start the Tilt development environment. Tilt provides a web interface for monitoring NFD worker and master progress, logs, and automatically rebuilds and redeploys on code changes. ```shell tilt up ``` -------------------------------- ### OS Release Label Template Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Creates labels for operating system release information. Requires 'system.osRelease' feature with ID and VERSION_ID.major. ```yaml labelsTemplate: | {{ range .system.osrelease }}system-{{ .Name }}={{ .Value }} {{ end }} matchFeatures: - feature: system.osRelease matchExpressions: ID: {op: Exists} VERSION_ID.major: {op: Exists} ``` -------------------------------- ### Local feature source file content Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Example content for a local feature file located in /etc/kubernetes/node-feature-discovery/features.d/. ```plaintext feature.node.kubernetes.io/my-feature.1 feature.node.kubernetes.io/my-feature.2=myvalue vendor.io/my-feature.3=456 ``` -------------------------------- ### Build Image with Custom Build Command (Environment) Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Build the NFD container image using a custom build command specified via an environment variable. This example uses `buildah bud`. ```bash IMAGE_BUILD_CMD="buildah bud" make ``` -------------------------------- ### OCI Artifact Manifest Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/image-compatibility.md A JSON manifest for an OCI artifact storing image compatibility metadata. ```json { "schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", "artifactType": "application/vnd.nfd.image-compatibility.v1alpha1", "config": { "mediaType": "application/vnd.oci.empty.v1+json", "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a", "size": 2 }, "layers": [ { "mediaType": "application/vnd.nfd.image-compatibility.spec.v1alpha1+yaml", "digest": "sha256:4a47f8ae4c713906618413cb9795824d09eeadf948729e213a1ba11a1e31d052", "size": 1710 } ], "subject": { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270", "size": 7682 }, "annotations": { "oci.opencontainers.image.created": "2024-03-27T08:08:08Z" } } ``` -------------------------------- ### Build Image with Custom Build Command (Makefile Override) Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Build the NFD container image using a custom build command specified directly in the make command. This example uses `buildah bud`. ```bash make IMAGE_BUILD_CMD="buildah bud" ``` -------------------------------- ### Custom Feature Source Configuration Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md An example nfd-worker configuration enabling the 'custom' label source. It defines a rule to create a node label based on loaded kernel modules and kernel configuration options. ```yaml core: labelSources: ["custom"] sources: custom: - name: "my sample rule" labels: "feature.node.kubenernetes.io/my-sample-feature": "true" matchFeatures: - feature: kernel.loadedmodule matchExpressions: dummy: {op: Exists} - feature: kernel.config matchExpressions: X86: {op: In, value: ["y"]} ``` -------------------------------- ### Deploy NFD-Topology-Updater with Helm Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/nfd-topology-updater.md Command to install NFD with the topology updater and CRD creation enabled. ```bash helm install nfd node-feature-discovery \ --set topologyUpdater.enable=true \ --set topologyUpdater.createCRDs=true ``` -------------------------------- ### Configure NFD master label namespaces Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Command line example for restricting or allowing specific label namespaces in NFD master. ```bash nfd-master -deny-label-ns="*" -extra-label-ns=example.com ``` -------------------------------- ### PCI Device Label Template Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Generates labels for each matched PCI network controller device. Requires 'pci.device' feature with specific class and vendor. ```yaml labelsTemplate: | {{ range .pci.device }}vendor-{{ .class }}-{{ .device }}.present=true {{ end }} matchFeatures: - feature: pci.device matchExpressions: class: {op: InRegexp, value: ["^02"]} vendor: ["0fff"] ``` -------------------------------- ### Verify NFD installation Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/get-started/quick-start.md Checks the status of NFD daemonsets and deployments. ```bash $ kubectl -n node-feature-discovery get ds,deploy NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE daemonset.apps/nfd-node-feature-discovery-worker 2 2 2 2 2 20s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/nfd-node-feature-discovery-gc 1/1 1 1 20s deployment.apps/nfd-node-feature-discovery-master 1/1 1 1 20s ``` -------------------------------- ### Deploy topology updater with Helm Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/get-started/quick-start.md Upgrades the NFD installation to enable the topology updater. ```bash helm upgrade --install -n node-feature-discovery --create-namespace nfd {{ site.helm_oci_repo }} --version {{ site.helm_chart_version }} --set topologyUpdater.enable=true ``` -------------------------------- ### Configure Feature Sources Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-commandline-reference.md The -feature-sources flag specifies enabled feature sources. 'all' enables all sources, and a '-' prefix disables a source. This example enables all sources except 'pci'. This flag takes precedence over the config file option. ```bash nfd-worker -feature-sources=all,-pci ``` -------------------------------- ### Override Configuration Options with -options Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-commandline-reference.md The -options flag allows overriding configuration file options directly from the command line using JSON or YAML format. This example whitelists specific CPU attributes. ```bash nfd-worker -options='{"sources":{"cpu":{"cpuid":{"attributeWhitelist":["AVX","AVX2"]}}}}' ``` -------------------------------- ### Configure Label Sources Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-commandline-reference.md The -label-sources flag specifies enabled label sources. 'all' enables all sources, and a '-' prefix disables a source. This example enables 'kernel', 'system', and 'local' sources. This flag takes precedence over the config file option. ```bash nfd-worker -label-sources=kernel,system,local ``` -------------------------------- ### NodeFeatureRule Custom Resource Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Creates node labels based on feature matching rules. Requires specific kernel modules to be loaded or kernel configurations to be set. ```yaml apiVersion: nfd.k8s-sigs.io/v1alpha1 kind: NodeFeatureRule metadata: name: my-sample-rule-object spec: rules: - name: "my sample rule" labels: "feature.node.kubernetes.io/my-sample-feature": "true" matchFeatures: - feature: kernel.loadedmodule matchExpressions: dummy: {op: Exists} - feature: kernel.config matchExpressions: X86: {op: In, value: ["y"]} ``` -------------------------------- ### Define a complex NodeFeatureRule Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md A referential example demonstrating multiple match expressions across CPU, kernel, and PCI features. ```yaml - name: "my feature rule" labels: "feature.node.kubernetes.io/my-special-feature": "my-value" matchFeatures: - feature: cpu.cpuid matchExpressions: AVX512F: {op: Exists} - feature: kernel.version matchExpressions: major: {op: In, value: ["5"]} minor: {op: Gt, value: ["1"]} - feature: pci.device matchExpressions: vendor: {op: In, value: ["8086"]} class: {op: In, value: ["0200"]} ``` -------------------------------- ### Apply NodeFeatureRule Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Applies a NodeFeatureRule custom resource using kubectl. The labeling may be delayed by the nfd-worker's sleep interval. ```bash kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/{{ site.release }}/examples/nodefeaturerule.yaml ``` -------------------------------- ### Example Feature File with Expiry Times Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Demonstrates how multiple expiry times in a feature file affect which features are processed. Only features with expiry times in the future relative to the processing time are included. ```plaintext # +expiry-time=2012-07-28T11:22:33Z vendor.io/feature1=featureValue # +expiry-time=2080-07-28T11:22:33Z vendor.io/feature2=featureValue2 # +expiry-time=2070-07-28T11:22:33Z vendor.io/feature3=featureValue3 # +expiry-time=2002-07-28T11:22:33Z vendor.io/feature4=featureValue4 ``` -------------------------------- ### Configure NFD Instance Name Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/master-commandline-reference.md Use the -instance flag to run multiple NFD deployments in parallel by separating node annotations. The instance name must start and end with an alphanumeric character. ```bash nfd-master -instance=network ``` -------------------------------- ### Define a custom kernel module rule Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Example configuration for a custom rule that labels nodes based on the presence of a loaded kernel module. ```yaml - name: "my e1000 rule" labels: "feature.node.kubenernetes.io/e1000.present": "true" matchFeatures: - feature: kernel.loadedmodule matchExpressions: e1000: {op: Exists} ``` -------------------------------- ### Example Output of Feature File Exclusion Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Shows the resulting `local.features` and `local.labels` sets, and node labels after processing a feature file with exclusion directives. ```yaml local.features: foo: baz vendor.io/my-feature: value local.labels: vendor.io/label-only: value vendor.io/my-feature: value ``` -------------------------------- ### Example NodeResourceTopology Object Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/custom-resources.md This YAML defines a NodeResourceTopology object, illustrating resource allocation across different zones on a node. It's used to provide granular hardware topology information. ```yaml apiVersion: topology.node.k8s.io/v1alpha1 kind: NodeResourceTopology metadata: name: node1 topologyPolicies: ["SingleNUMANodeContainerLevel"] zones: - name: node-0 type: Node resources: - name: cpu capacity: 20 allocatable: 16 available: 10 - name: vendor/nic1 capacity: 3 allocatable: 3 available: 3 - name: node-1 type: Node resources: - name: cpu capacity: 30 allocatable: 30 available: 15 - name: vendor/nic2 capacity: 6 allocatable: 6 available: 6 - name: node-2 type: Node resources: - name: cpu capacity: 30 allocatable: 30 available: 15 - name: vendor/nic1 capacity: 3 allocatable: 3 available: 3 ``` -------------------------------- ### Override Environment Variables for Tilt Build Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Export environment variables before running 'tilt up' to override default values used in the Tiltfile during image builds. This example shows how to set a custom IMAGE_TAG_NAME. ```shell export IMAGE_TAG_NAME="v1" tilt up ``` -------------------------------- ### Verify NodeResourceTopology CRD installation error Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/nfd-topology-updater.md Example of the error message displayed when the required CRD is missing. ```plaintext NodeResourceTopology CRD "noderesourcetopologies.topology.node.k8s.io" is not installed ``` -------------------------------- ### Run with discovery script help Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/demo/README.md Displays usage information for the run-with-discovery.sh script. ```sh > ./run-with-discovery.sh -h Usage: run-with-discovery.sh [-a APPLICATION_NAME] Runs pods ten times with discovery enabled. -a APPLICATION_NAME run the pods with APPLICATION_NAME application. APPLICATION_NAME can be one of parsec or cloverleaf. ``` -------------------------------- ### Display Help via Docker Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/topology-updater-commandline-reference.md View available command line flags when running inside a container. ```bash docker run {{ site.container_image }} \ nfd-topology-updater -help ``` -------------------------------- ### Serve NFD Documentation Locally Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Build and serve the NFD documentation locally using this command. It runs the build process in a container and makes the documentation accessible at localhost:4000. Changes in the docs/ directory will automatically trigger a rebuild. ```bash make site-serve ``` -------------------------------- ### Display Help Message Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/gc-commandline-reference.md Execute `nfd-gc -help` to view all available command line flags and their descriptions. This can also be run within a Docker container using the specified image. ```bash docker run {{ site.container_image }} nfd-gc -help ``` ```bash nfd-gc -help ``` -------------------------------- ### Run nfd-topology-updater locally Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Build and run the nfd-topology-updater binary. Requires access to the kubelet pod-resources socket and HTTP API. ```bash make build KUBERNETES_NAMESPACE=default NODE_NAME=nonexistent-node ./bin/nfd-topology-updater -kubeconfig ~/.kube/config -kubelet-config-uri http://127.0.0.1:10255 ``` -------------------------------- ### Display nfd-master Help Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/master-commandline-reference.md Execute this command to view all available command-line flags and their descriptions for nfd-master. This is useful for understanding the full range of options. ```bash nfd-master -help ``` ```bash docker run {{ site.container_image }} nfd-master -help ``` -------------------------------- ### Define a NodeFeatureGroup Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Example of a NodeFeatureGroup resource that groups nodes based on kernel version. ```yaml apiVersion: nfd.k8s-sigs.io/v1alpha1 kind: NodeFeatureGroup metadata: name: node-feature-group-example spec: featureGroupRules: - name: "kernel version" matchFeatures: - feature: kernel.version matchExpressions: major: {op: In, value: ["6"]} status: nodes: - name: node-1 - name: node-2 - name: node-3 ``` -------------------------------- ### Deploy topology updater with Kustomize Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/get-started/quick-start.md Deploys the topology updater using the specific overlay. ```bash kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/topologyupdater?ref={{ site.release }}" ``` -------------------------------- ### Push Multi-Arch Container Images Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Push the manifest-list and associated multi-arch container images to a remote registry. ```bash make push-all ``` -------------------------------- ### Deploy NFD using Kustomize Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/get-started/index.md Deploy Node Feature Discovery using kubectl and Kustomize. This method is an alternative to Helm. ```bash kubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref={{ site.release }} ``` -------------------------------- ### Local feature source label translation Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md The resulting node labels generated from the local feature source example. ```yaml feature.node.kubernetes.io/my-feature.1: "true" feature.node.kubernetes.io/my-feature.2: "myvalue" vendor.io/my-feature.3: "456" ``` -------------------------------- ### Deploy Node Feature Discovery with Kustomize Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/README.md Deploy Node Feature Discovery using kubectl and Kustomize. Specify the correct overlay path and Git reference. ```bash kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref=v0.18.3" ``` -------------------------------- ### Build Multi-Arch Container Images Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Build container images for multiple architectures (default: linux/amd64, linux/arm64). This command generates a manifest-list. ```bash make image-all ``` -------------------------------- ### Enable NodeFeatureGroup API Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/master-commandline-reference.md Use the -feature-gates flag to enable specific non-GA features. This example enables the NodeFeatureGroupAPI. ```bash nfd-master -feature-gates NodeFeatureGroupAPI=true ``` -------------------------------- ### Define a NodeFeatureRule with dynamic label values Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Example of using the @ notation to inject detected feature attributes into node labels. ```yaml apiVersion: nfd.k8s-sigs.io/v1alpha1 kind: NodeFeatureRule metadata: name: my-sample-rule-object spec: rules: - name: "my dynamic label value rule" labels: feature.node.kubernetes.io/linux-lsm-enabled: "@kernel.config.LSM" feature.node.kubernetes.io/custom-label: "customlabel" ``` -------------------------------- ### Configure NodeFeatureRule labels Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/feature-gates.md Example of a label configuration in a NodeFeatureRule that is subject to automatic prefixing based on the DisableAutoPrefix feature gate. ```yaml labels: foo: bar ``` -------------------------------- ### Deploy NFD and topology updater separately Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/kustomize.md Combines the default overlay with the topology updater overlay to deploy all components as separate pods. ```bash kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref={{ site.release }}" kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/topologyupdater?ref={{ site.release }}" ``` -------------------------------- ### Define Extended Resources in NodeFeatureRule Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Example of using the extendedResources field to advertise dynamic and static resources based on kernel features. ```yaml apiVersion: nfd.k8s-sigs.io/v1alpha1 kind: NodeFeatureRule metadata: name: my-extended-resource-rule spec: rules: - name: "my extended resource rule" extendedResources: vendor.io/dynamic: "@kernel.version.major" vendor.io/static: "123" matchFeatures: - feature: kernel.version matchExpressions: major: {op: Exists} ``` -------------------------------- ### Run without discovery script help Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/demo/README.md Displays usage information for the run-without-discovery.sh script. ```sh >./run-without-discovery.sh -h Usage: run-without-discovery.sh [-a APPLICATION_NAME] Runs ten pods without discovery enabled with the specified application. -a APPLICATION_NAME run the pods with APPLICATION_NAME application. APPLICATION_NAME can be one of parsec or cloverleaf. ``` -------------------------------- ### Define an NFD compatibility artifact payload Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/enhancements/1845-nfd-image-compatibility/README.md Example YAML configuration for an NFD compatibility artifact, including version, weight, and feature matching rules. ```yaml version: v1alpha1 compatibilities: - tag: "prefered" weight: 10 description: "Prefered node configuration" rules: - name: "kernel and cpu" matchFeatures: - feature: kernel.loadedmodule matchExpressions: vfio-pci: {op: Exists} - feature: cpu.model matchExpressions: vendor_id: {op: In, value: ["Intel", "Amd"]} - tag: "fallback" weight: 1 description: "Minimal required configuration" rules: - name: "cpu" matchFeatures: - feature: cpu.model matchExpressions: vendor_id: {op: In, value: ["Intel", "Amd"]} ``` -------------------------------- ### Build NFD Documentation HTML Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Generate the static HTML documentation for NFD. The output will be placed in the docs/_site/ directory. ```bash make site-build ``` -------------------------------- ### NodeFeature Custom Resource Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Defines custom node features and directly requested labels. The 'nfd.node.kubernetes.io/node-name' label is required to target a specific node. ```yaml apiVersion: nfd.k8s-sigs.io/v1alpha1 kind: NodeFeature metadata: labels: nfd.node.kubernetes.io/node-name: node-1 name: vendor-features-for-node-1 spec: # Features for NodeFeatureRule matching features: flags: vendor.flags: elements: feature-x: {} feature-y: {} attributes: vendor.config: elements: setting-a: "auto" knob-b: "123" instances: vendor.devices: elements: - attributes: model: "dev-1000" vendor: "acme" - attributes: model: "dev-2000" vendor: "acme" # Labels to be created labels: vendor.io/feature.enabled: "true" ``` -------------------------------- ### One-Shot Feature Detection Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-commandline-reference.md The -oneshot flag causes nfd-worker to exit after a single pass of feature detection. This example also includes the -no-publish flag for a dry-run. ```bash nfd-worker -oneshot -no-publish ``` -------------------------------- ### Configure NFD-Worker via command line Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/nfd-worker.md Use the -options flag to pass configuration directly to the worker, overriding file-based settings. ```bash -options='{"sources": { "pci": { "deviceClassWhitelist": ["12"] } } }' ``` -------------------------------- ### OCI Artifact Manifest Example Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/enhancements/1845-nfd-image-compatibility/README.md This JSON structure represents an OCI artifact manifest for image compatibility metadata. It specifies the artifact type, configuration, layers, and the subject image it relates to. ```json { "schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", "artifactType": "application/vnd.k8s.nfd.image-compatibility.v1", "config": { "mediaType": "application/vnd.oci.empty.v1+json", "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a", "size": 2 }, "layers": [ { "mediaType": "application/vnd.k8s.nfd.image-compatibility.spec.v1+yaml", "digest": "sha256:4a47f8ae4c713906618413cb9795824d09eeadf948729e213a1ba11a1e31d052", "size": 1710 } ], "subject": { "mediaType": "application/vnd.oci.image.manifest.v1+json", "digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270", "size": 7682 }, "annotations": { "oci.opencontainers.image.created": "2024-03-27T08:08:08Z" } } ``` -------------------------------- ### Download Node Feature Discovery Source Code Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Clone the NFD repository to your local machine to begin building from source. ```bash git clone https://github.com/kubernetes-sigs/node-feature-discovery cd node-feature-discovery ``` -------------------------------- ### Aggregate logs and plot script help Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/demo/README.md Displays usage information for the aggregate-logs-and-plot.sh script. ```sh >./aggregate-logs-and-plot.sh -h Usage: aggregate-logs-and-plot.sh [-a APPLICATION_NAME] Aggregate the results from the specified application and plot the result. -a APPLICATION_NAME run the pods with APPLICATION_NAME application. APPLICATION_NAME can be one of parsec or cloverleaf ``` -------------------------------- ### Configure USB device class whitelist Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-configuration-reference.md Specify USB device classes to be published as labels. ```yaml sources: usb: deviceClassWhitelist: ["ef", "ff"] ``` -------------------------------- ### Upgrade NFD from v0.8 - v0.11 Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/deployment/helm/node-feature-discovery/README.md Upgrades NFD from versions 0.8 to 0.11. This involves uninstalling the old deployment, installing a new one with master disabled, waiting for workers, and then enabling the master. ```bash export NFD_NS=node-feature-discovery export HELM_INSTALL_NAME=nfd # Uninstall the old NFD deployment helm uninstall $HELM_INSTALL_NAME --namespace $NFD_NS # Install the new NFD deployment helm install $HELM_INSTALL_NAME oci://gcr.io/k8s-staging-nfd/charts/node-feature-discovery --version 0.0.0-master --namespace $NFD_NS --set master.enable=false # Wait for NFD Worker to be ready kubectl wait --timeout=-1s --for=condition=ready pod -l app.kubernetes.io/name=node-feature-discovery --namespace $NFD_NS # Enable the NFD Master helm upgrade $HELM_INSTALL_NAME oci://gcr.io/k8s-staging-nfd/charts/node-feature-discovery --version 0.0.0-master --namespace $NFD_NS --set master.enable=true ``` -------------------------------- ### Verify Node Feature Discovery Deployment Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/README.md Check the status of Node Feature Discovery pods and verify that node labels for discovered features are applied. ```bash $ kubectl -n node-feature-discovery get all NAME READY STATUS RESTARTS AGE pod/nfd-gc-565fc85d9b-94jpj 1/1 Running 0 18s pod/nfd-master-6796d89d7b-qccrq 1/1 Running 0 18s pod/nfd-worker-nwdp6 1/1 Running 0 18s ... ``` ```bash $ kubectl get no -o json | jq ".items[].metadata.labels" { "kubernetes.io/arch": "amd64", "kubernetes.io/os": "linux", "feature.node.kubernetes.io/cpu-cpuid.ADX": "true", "feature.node.kubernetes.io/cpu-cpuid.AESNI": "true", ... } ``` -------------------------------- ### Schedule pod using NFD labels Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/get-started/quick-start.md Creates a pod that uses nodeSelector to target a specific hardware feature. ```bash $ cat << EOF | kubectl apply -f - apiVersion: v1 kind: Pod metadata: name: feature-dependent-pod spec: containers: - image: registry.k8s.io/pause name: pause nodeSelector: # Select a valid feature feature.node.kubernetes.io/cpu-cpuid.AESNI: 'true' EOF pod/feature-dependent-pod created ``` -------------------------------- ### Configure kernel config file path Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-configuration-reference.md Specify the path to the kernel configuration file. ```yaml sources: kernel: kconfigFile: "/path/to/kconfig" ``` -------------------------------- ### Advanced PCI Device Label Template Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Demonstrates advanced templating using Go's len, Sprig's first, trim, and substr functions to count and format PCI network controller information. Matches Intel network controllers. ```yaml labelsTemplate: | num-intel-network-controllers={{ .pci.device | len }} first-intel-network-controllers={{ (.pci.device | first).class | trim | substr 0 63 }} matchFeatures: - feature: pci.device matchExpressions: vendor: {op: In, value: ["8086"]} class: {op: In, value: ["0200"]} ``` -------------------------------- ### Override configuration with -options Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/master-commandline-reference.md Use the -options flag to pass JSON or YAML configuration directly from the command line, overriding values in the config file. ```bash nfd-master -options='{"noPublish": true}' ``` -------------------------------- ### Specify Configuration File Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/master-commandline-reference.md Provide the path to the nfd-master configuration file using the -config flag. The default path is /etc/kubernetes/node-feature-discovery/nfd-master.conf. ```bash nfd-master -config=/opt/nfd/master.conf ``` -------------------------------- ### Uninstall Node Feature Discovery Components Individually Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/kustomize.md This command sequence allows for the granular uninstallation of NFD components. It targets specific resources like daemonsets, deployments, services, and service accounts within the 'node-feature-discovery' namespace, as well as cluster-level roles and bindings. Adjust the NFD_NS variable if NFD was installed in a different namespace. ```bash NFD_NS=node-feature-discovery kubectl -n $NFD_NS delete ds nfd-worker kubectl -n $NFD_NS delete deploy nfd-master kubectl -n $NFD_NS delete svc nfd-master kubectl -n $NFD_NS delete sa nfd-master kubectl delete clusterrole nfd-master kubectl delete clusterrolebinding nfd-master ``` -------------------------------- ### Push Container Image to Registry Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Push the built container image to a remote registry. Replace `` with your desired tag. ```bash docker push ``` -------------------------------- ### Match Kernel Module and OS Version Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Create a rule that requires a specific kernel module to be loaded and matches a regular expression for the OS release name and a version ID. This is useful for ensuring compatibility with specific system configurations. ```yaml - name: "my multi-feature rule" labels: my-special-multi-feature: "true" matchFeatures: - feature: kernel.loadedmodule matchExpressions: e1000: {op: Exists} - feature: system.osrelease matchExpressions: NAME: {op: InRegexp, values: ["^openSUSE"]} VERSION_ID.major: {op: Gt, values: ["14"]} ``` -------------------------------- ### Enable Prometheus metrics via Helm Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/metrics.md Use these flags during Helm deployment to enable Prometheus scraping. ```bash --set prometheus.enable=true ``` ```bash --set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false ``` -------------------------------- ### Device and Rule Attributes Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/usage/customization-guide.md Documentation for USB device attributes and rule matching status. ```APIDOC ## Device and Rule Attributes ### usb.device - **Description**: USB devices present in the system. - **Parameters**: `` (string) - Value of the sysfs device attribute (class, vendor, device, serial). ### rule.matched - **Description**: Previously matched rules. - **Parameters**: `` (string) - Label or var from a preceding rule that matched. ``` -------------------------------- ### Build Image with Custom Registry Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Build the NFD container image using a custom registry URI. This overrides the default `IMAGE_REGISTRY` value. ```bash make IMAGE_REGISTRY= ``` -------------------------------- ### Build Node Feature Discovery Binaries Locally Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Compile the NFD binaries locally. The compiled binaries will be placed in the `bin/` directory. ```bash make build ``` -------------------------------- ### Configure PCI device class whitelist Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-configuration-reference.md Specify PCI device classes to be published as labels. ```yaml sources: pci: deviceClassWhitelist: ["0200", "03"] ``` -------------------------------- ### Deploy NFD components with topology updater Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/kustomize.md Deploys nfd-master, nfd-worker, and nfd-topology-updater as separate pods. ```bash kubectl apply -k "https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/master-worker-topologyupdater?ref={{ site.release }}" ``` -------------------------------- ### Enable All Feature Sources Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/reference/worker-configuration-reference.md Enable all available feature sources, excluding specific ones like 'cpu' and 'local'. This is useful for enabling most sources while disabling a few. ```yaml core: # Enable all but cpu and local sources featureSources: - "all" - "-cpu" - "-local" ``` -------------------------------- ### Run unit tests Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Execute unit tests manually within the source code tree. ```bash make test ``` -------------------------------- ### Deploy Node Feature Discovery with Custom Namespace Source: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/developer-guide/index.md Generate Kubernetes YAML manifests for deployment using a custom namespace and apply them to your cluster. This command uses Kustomize. ```bash K8S_NAMESPACE=my-ns make yamls kubectl apply -k . ```