[{"title":"Developer guide","layout":"default","sort":1,"content":"
git clone https://github.com/kubernetes-sigs/node-feature-discovery\ncd node-feature-discovery\n
See customizing the build below for altering the\ncontainer image registry, for example.
\n\nmake\n
Optional, this example with Docker.
\n\ndocker push <IMAGE_TAG>\n
To use your published image from the step above instead of the\nk8s.gcr.io/nfd/node-feature-discovery
image, edit image
\nattribute in the spec template(s) to the new location\n(<registry-name>/<image-name>[:<version>]
).
The yamls
makefile generates a kustomization.yaml
matching your locally\nbuilt image and using the deploy/overlays/default
deployment. See\nbuild customization below for configurability, e.g.\nchanging the deployment namespace.
K8S_NAMESPACE=my-ns make yamls\nkubectl apply -k .\n
You can use alternative deployment methods by modifying the auto-generated\nkustomization file. For example, deploying worker and master in the same pod by\npointing to deployment/overlays/default-combined
.
You can also build the binaries locally
\n\nmake build\n
This will compile binaries under bin/
There are several Makefile variables that control the build process and the\nname of the resulting container image. The following are targeted targeted for\nbuild customization and they can be specified via environment variables or\nmakefile overrides.
\n\nVariable | \nDescription | \nDefault value | \n
---|---|---|
HOSTMOUNT_PREFIX | \nPrefix of system directories for feature discovery (local builds) | \n/ (local builds) /host- (container builds) | \n
IMAGE_BUILD_CMD | \nCommand to build the image | \ndocker build | \n
IMAGE_BUILD_EXTRA_OPTS | \nExtra options to pass to build command | \nempty | \n
IMAGE_PUSH_CMD | \nCommand to push the image to remote registry | \ndocker push | \n
IMAGE_REGISTRY | \nContainer image registry to use | \nk8s.gcr.io/nfd | \n
IMAGE_TAG_NAME | \nContainer image tag name | \n<nfd version> | \n
IMAGE_EXTRA_TAG_NAMES | \nAdditional container image tag(s) to create when building image | \nempty | \n
K8S_NAMESPACE | \nnfd-master and nfd-worker namespace | \nkube-system | \n
KUBECONFIG | \nKubeconfig for running e2e-tests | \nempty | \n
E2E_TEST_CONFIG | \nParameterization file of e2e-tests (see example) | \nempty | \n
OPENSHIFT | \nNon-empty value enables OpenShift specific support (currently only effective in e2e tests) | \nempty | \n
BASE_IMAGE_FULL | \nContainer base image for target image full (–target full) | \ndebian:buster-slim | \n
BASE_IMAGE_MINIMAL | \nContainer base image for target image minimal (–target minimal) | \ngcr.io/distroless/base | \n
For example, to use a custom registry:
\n\nmake IMAGE_REGISTRY=<my custom registry uri>\n
Or to specify a build tool different from Docker, It can be done in 2 ways:
\n\nvia environment
\n\n IMAGE_BUILD_CMD=\"buildah bud\" make\n
by overriding the variable value
\n\n make IMAGE_BUILD_CMD=\"buildah bud\"\n
Unit tests are automatically run as part of the container image build. You can\nalso run them manually in the source code tree by simply running:
\n\nmake test\n
End-to-end tests are built on top of the e2e test framework of Kubernetes, and,\nthey required a cluster to run them on. For running the tests on your test\ncluster you need to specify the kubeconfig to be used:
\n\nmake e2e-test KUBECONFIG=$HOME/.kube/config\n
You can run NFD locally, either directly on your host OS or in containers for\ntesting and development purposes. This may be useful e.g. for checking\nfeatures-detection.
\n\nWhen running as a standalone container labeling is expected to fail because\nKubernetes API is not available. Thus, it is recommended to use -no-publish
\ncommand line flag. E.g.
$ export NFD_CONTAINER_IMAGE=k8s.gcr.io/nfd/node-feature-discovery:v0.9.0\n$ docker run --rm --name=nfd-test ${NFD_CONTAINER_IMAGE} nfd-master -no-publish\n2019/02/01 14:48:21 Node Feature Discovery Master <NFD_VERSION>\n2019/02/01 14:48:21 gRPC server serving on port: 8080\n
Command line flags of nfd-master:
\n\n$ docker run --rm ${NFD_CONTAINER_IMAGE} nfd-master -help\nUsage of nfd-master:\n -ca-file string\n Root certificate for verifying connections\n -cert-file string\n Certificate used for authenticating connections\n -extra-label-ns value\n Comma separated list of allowed extra label namespaces\n -instance string\n Instance name. Used to separate annotation namespaces for multiple parallel deployments.\n -key-file string\n Private key matching -cert-file\n -kubeconfig string\n Kubeconfig to use\n -label-whitelist value\n Regular expression to filter label names to publish to the Kubernetes API server. NB: the label namespace is omitted i.e. the filter is only applied to the name part after '/'.\n -no-publish\n Do not publish feature labels\n -port int\n Port on which to listen for connections. (default 8080)\n -prune\n Prune all NFD related attributes from all nodes of the cluaster and exit.\n -resource-labels value\n Comma separated list of labels to be exposed as extended resources.\n -verify-node-name\n Verify worker node name against the worker's TLS certificate. Only takes effect when TLS authentication has been enabled.\n -version\n Print version and exit.\n
In order to run nfd-worker as a “stand-alone” container against your\nstandalone nfd-master you need to run them in the same network namespace:
\n\n$ docker run --rm --network=container:nfd-test ${NFD_CONTAINER_IMAGE} nfd-worker\n2019/02/01 14:48:56 Node Feature Discovery Worker <NFD_VERSION>\n...\n
If you just want to try out feature discovery without connecting to nfd-master,\npass the -no-publish
flag to nfd-worker.
Command line flags of nfd-worker:
\n\n$ docker run --rm ${NFD_CONTAINER_IMAGE} nfd-worker -help\nUsage of nfd-worker:\n -ca-file string\n Root certificate for verifying connections\n -cert-file string\n Certificate used for authenticating connections\n -config string\n Config file to use. (default \"/etc/kubernetes/node-feature-discovery/nfd-worker.conf\")\n -key-file string\n Private key matching -cert-file\n -label-whitelist value\n Regular expression to filter label names to publish to the Kubernetes API server. NB: the label namespace is omitted i.e. the filter is only applied to the name part after '/'. DEPRECATED: This parameter should be set via the config file.\n -no-publish\n Do not publish discovered features, disable connection to nfd-master.\n -oneshot\n Do not publish feature labels\n -options string\n Specify config options from command line. Config options are specified in the same format as in the config file (i.e. json or yaml). These options\n -server string\n NFD server address to connecto to. (default \"localhost:8080\")\n -server-name-override string\n Hostname expected from server certificate, useful in testing\n -sleep-interval duration\n Time to sleep between re-labeling. Non-positive value implies no re-labeling (i.e. infinite sleep). DEPRECATED: This parameter should be set via the config file\n -sources value\n Comma separated list of feature sources. Special value 'all' enables all feature sources. DEPRECATED: This parameter should be set via the config file\n -version\n Print version and exit.\n
NOTE Some feature sources need certain directories and/or files from the\nhost mounted inside the NFD container. Thus, you need to provide Docker with the\ncorrect --volume
options in order for them to work correctly when run\nstand-alone directly with docker run
. See the\ndefault deployment\nfor up-to-date information about the required volume mounts.
All documentation resides under the\ndocs\ndirectory in the source tree. It is designed to be served as a html site by\nGitHub Pages.
\n\nBuilding the documentation is containerized in order to fix the build\nenvironment. The recommended way for developing documentation is to run:
\n\nmake site-serve\n
This will build the documentation in a container and serve it under\nlocalhost:4000/ making it easy to verify the results.\nAny changes made to the docs/
will automatically re-trigger a rebuild and are\nreflected in the served content and can be inspected with a simple browser\nrefresh.
In order to just build the html documentation run:
\n\nmake site-build\n
This will generate html documentation under docs/_site/
.
This software enables node feature discovery for Kubernetes. It detects\nhardware features available on each node in a Kubernetes cluster, and\nadvertises those features using node labels.
\n\nNFD consists of two software components:
\n\nNFD-Master is the daemon responsible for communication towards the Kubernetes\nAPI. That is, it receives labeling requests from the worker and modifies node\nobjects accordingly.
\n\nNFD-Worker is a daemon responsible for feature detection. It then communicates\nthe information to nfd-master which does the actual node labeling. One\ninstance of nfd-worker is supposed to be running on each node of the cluster,
\n\nFeature discovery is divided into domain-specific feature sources:
\n\nEach feature source is responsible for detecting a set of features which. in\nturn, are turned into node feature labels. Feature labels are prefixed with\nfeature.node.kubernetes.io/
and also contain the name of the feature source.\nNon-standard user-specific feature labels can be created with the local and\ncustom feature sources.
An overview of the default feature labels:
\n\n{\n \"feature.node.kubernetes.io/cpu-<feature-name>\": \"true\",\n \"feature.node.kubernetes.io/custom-<feature-name>\": \"true\",\n \"feature.node.kubernetes.io/iommu-<feature-name>\": \"true\",\n \"feature.node.kubernetes.io/kernel-<feature name>\": \"<feature value>\",\n \"feature.node.kubernetes.io/memory-<feature-name>\": \"true\",\n \"feature.node.kubernetes.io/network-<feature-name>\": \"true\",\n \"feature.node.kubernetes.io/pci-<device label>.present\": \"true\",\n \"feature.node.kubernetes.io/storage-<feature-name>\": \"true\",\n \"feature.node.kubernetes.io/system-<feature name>\": \"<feature value>\",\n \"feature.node.kubernetes.io/usb-<device label>.present\": \"<feature value>\",\n \"feature.node.kubernetes.io/<file name>-<feature name>\": \"<feature value>\"\n}\n
NFD also annotates nodes it is running on:
\n\nAnnotation | \nDescription | \n
---|---|
[<instance>.]nfd.node.kubernetes.io/master.version | \nVersion of the nfd-master instance running on the node. Informative use only. | \n
[<instance>.]nfd.node.kubernetes.io/worker.version | \nVersion of the nfd-worker instance running on the node. Informative use only. | \n
[<instance>.]nfd.node.kubernetes.io/feature-labels | \nComma-separated list of node labels managed by NFD. NFD uses this internally so must not be edited by users. | \n
[<instance>.]nfd.node.kubernetes.io/extended-resources | \nComma-separated list of node extended resources managed by NFD. NFD uses this internally so must not be edited by users. | \n
NOTE: the --instance
\ncommand line flag affects the annotation names
Unapplicable annotations are not created, i.e. for example master.version is\nonly created on nodes running nfd-master.
\n\n","dir":"/get-started/","name":"introduction.md","path":"get-started/introduction.md","url":"/get-started/introduction.html"},{"title":"Get started","layout":"default","sort":1,"content":"Welcome to Node Feature Discovery – a Kubernetes add-on for detecting hardware\nfeatures and system configuration!
\n\nContinue to:
\n\nIntroduction for more details on the\nproject.
\nQuick start for quick step-by-step\ninstructions on how to get NFD running on your cluster.
\n$ kubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref=v0.9.0\n namespace/node-feature-discovery created\n serviceaccount/nfd-master created\n clusterrole.rbac.authorization.k8s.io/nfd-master created\n clusterrolebinding.rbac.authorization.k8s.io/nfd-master created\n configmap/nfd-worker-conf created\n service/nfd-master created\n deployment.apps/nfd-master created\n daemonset.apps/nfd-worker created\n\n$ kubectl -n node-feature-discovery get all\n NAME READY STATUS RESTARTS AGE\n pod/nfd-master-555458dbbc-sxg6w 1/1 Running 0 56s\n pod/nfd-worker-mjg9f 1/1 Running 0 17s\n...\n\n$ kubectl get no -o json | jq .items[].metadata.labels\n {\n \"beta.kubernetes.io/arch\": \"amd64\",\n \"beta.kubernetes.io/os\": \"linux\",\n \"feature.node.kubernetes.io/cpu-cpuid.ADX\": \"true\",\n \"feature.node.kubernetes.io/cpu-cpuid.AESNI\": \"true\",\n...\n\n
Advanced topics and reference.
\n","dir":"/advanced/","name":"index.md","path":"advanced/index.md","url":"/advanced/"},{"title":"Master cmdline reference","layout":"default","sort":2,"content":"To quickly view available command line flags execute nfd-master -help
.\nIn a docker container:
docker run k8s.gcr.io/nfd/node-feature-discovery:v0.9.0 nfd-master -help\n
Print usage and exit.
\n\nPrint version and exit.
\n\nThe -prune
flag is a sub-command like option for cleaning up the cluster. It\ncauses nfd-master to remove all NFD related labels, annotations and extended\nresources from all Node objects of the cluster and exit.
The -port
flag specifies the TCP port that nfd-master listens for incoming requests.
Default: 8080
\n\nExample:
\n\nnfd-master -port=443\n
The -instance
flag makes it possible to run multiple NFD deployments in\nparallel. In practice, it separates the node annotations between deployments so\nthat each of them can store metadata independently. The instance name must\nstart and end with an alphanumeric character and may only contain alphanumeric\ncharacters, -
, _
or .
.
Default: empty
\n\nExample:
\n\nnfd-master -instance=network\n
The -ca-file
is one of the three flags (together with -cert-file
and\n-key-file
) controlling master-worker mutual TLS authentication on the\nnfd-master side. This flag specifies the TLS root certificate that is used for\nauthenticating incoming connections. NFD-Worker side needs to have matching key\nand cert files configured in order for the incoming requests to be accepted.
Default: empty
\n\nNote: Must be specified together with -cert-file
and -key-file
Example:
\n\nnfd-master -ca-file=/opt/nfd/ca.crt -cert-file=/opt/nfd/master.crt -key-file=/opt/nfd/master.key\n
The -cert-file
is one of the three flags (together with -ca-file
and\n-key-file
) controlling master-worker mutual TLS authentication on the\nnfd-master side. This flag specifies the TLS certificate presented for\nauthenticating outgoing traffic towards nfd-worker.
Default: empty
\n\nNote: Must be specified together with -ca-file
and -key-file
Example:
\n\nnfd-master -cert-file=/opt/nfd/master.crt -key-file=/opt/nfd/master.key -ca-file=/opt/nfd/ca.crt\n
The -key-file
is one of the three flags (together with -ca-file
and\n-cert-file
) controlling master-worker mutual TLS authentication on the\nnfd-master side. This flag specifies the private key corresponding the given\ncertificate file (-cert-file
) that is used for authenticating outgoing\ntraffic.
Default: empty
\n\nNote: Must be specified together with -cert-file
and -ca-file
Example:
\n\nnfd-master -key-file=/opt/nfd/master.key -cert-file=/opt/nfd/master.crt -ca-file=/opt/nfd/ca.crt\n
The -verify-node-name
flag controls the NodeName based authorization of\nincoming requests and only has effect when mTLS authentication has been enabled\n(with -ca-file
, -cert-file
and -key-file
). If enabled, the worker node\nname of the incoming must match with the CN or a SAN in its TLS certificate. Thus,\nworkers are only able to label the node they are running on (or the node whose\ncertificate they present).
Node Name based authorization is disabled by default.
\n\nDefault: false
\n\nExample:
\n\nnfd-master -verify-node-name -ca-file=/opt/nfd/ca.crt \\\n -cert-file=/opt/nfd/master.crt -key-file=/opt/nfd/master.key\n
The -no-publish
flag disables all communication with the Kubernetes API\nserver, making a “dry-run” flag for nfd-master. No Labels, Annotations or\nExtendedResources (or any other properties of any Kubernetes API objects) are\nmodified.
Default: false
\n\nExample:
\n\nnfd-master -no-publish\n
The -label-whitelist
specifies a regular expression for filtering feature\nlabels based on their name. Each label must match against the given reqular\nexpression in order to be published.
Note: The regular expression is only matches against the “basename” part of the\nlabel, i.e. to the part of the name after ‘/’. The label namespace is omitted.
\n\nDefault: empty
\n\nExample:
\n\nnfd-master -label-whitelist='.*cpuid\\.'\n
The -extra-label-ns
flag specifies a comma-separated list of allowed feature\nlabel namespaces. By default, nfd-master only allows creating labels in the\ndefault feature.node.kubernetes.io
label namespace and its sub-namespaces\n(e.g. vendor.feature.node.kubernetes.io
). This option can be used to allow\nother vendor or application specific namespaces for custom labels from the\nlocal and custom feature sources.
The same namespace control and this flag applies Extended Resources (created\nwith -resource-labels
), too.
Default: empty
\n\nExample:
\n\nnfd-master -extra-label-ns=vendor-1.com,vendor-2.io\n
The -resource-labels
flag specifies a comma-separated list of features to be\nadvertised as extended resources instead of labels. Features that have integer\nvalues can be published as Extended Resources by listing them in this flag.
Default: empty
\n\nExample:
\n\nnfd-master -resource-labels=vendor-1.com/feature-1,vendor-2.io/feature-2\n
The following logging-related flags are inherited from the\nklog package.
\n\nIf true, adds the file directory to the header of the log messages.
\n\nDefault: false
\n\nLog to standard error as well as files.
\n\nDefault: false
\n\nWhen logging hits line file:N, emit a stack trace.
\n\nDefault: empty
\n\nIf non-empty, write log files in this directory.
\n\nDefault: empty
\n\nIf non-empty, use this log file.
\n\nDefault: empty
\n\nDefines the maximum size a log file can grow to. Unit is megabytes. If the\nvalue is 0, the maximum file size is unlimited.
\n\nDefault: 1800
\n\nLog to standard error instead of files
\n\nDefault: true
\n\nIf true, avoid header prefixes in the log messages.
\n\nDefault: false
\n\nIf true, avoid headers when opening log files.
\n\nDefault: false
\n\nLogs at or above this threshold go to stderr.
\n\nDefault: 2
\n\nNumber for the log level verbosity.
\n\nDefault: 0
\n\nComma-separated list of pattern=N
settings for file-filtered logging.
Default: empty
\n","dir":"/advanced/","name":"master-commandline-reference.md","path":"advanced/master-commandline-reference.md","url":"/advanced/master-commandline-reference.html"},{"title":"Quick start","layout":"default","sort":2,"content":"Minimal steps to deploy latest released version of NFD in your cluster.
\n\nDeploy with kustomize – creates a new namespace, service and required RBAC\nrules and deploys nfd-master and nfd-worker daemons.
\n\nkubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref=v0.9.0\n
Wait until NFD master and worker are running.
\n\n$ kubectl -n node-feature-discovery get ds,deploy\nNAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE\ndaemonset.apps/nfd-worker 3 3 3 3 3 <none> 5s\nNAME READY UP-TO-DATE AVAILABLE AGE\ndeployment.apps/nfd-master 1/1 1 1 17s\n
Check that NFD feature labels have been created
\n\n$ kubectl get no -o json | jq .items[].metadata.labels\n{\n \"beta.kubernetes.io/arch\": \"amd64\",\n \"beta.kubernetes.io/os\": \"linux\",\n \"feature.node.kubernetes.io/cpu-cpuid.ADX\": \"true\",\n \"feature.node.kubernetes.io/cpu-cpuid.AESNI\": \"true\",\n \"feature.node.kubernetes.io/cpu-cpuid.AVX\": \"true\",\n...\n
Create a pod targeting a distinguishing feature (select a valid feature from\nthe list printed on the previous step)
\n\n$ cat << EOF | kubectl apply -f -\napiVersion: v1\nkind: Pod\nmetadata:\n name: feature-dependent-pod\nspec:\n containers:\n - image: k8s.gcr.io/pause\n name: pause\n nodeSelector:\n # Select a valid feature\n feature.node.kubernetes.io/cpu-cpuid.AESNI: 'true'\nEOF\npod/feature-dependent-pod created\n
See that the pod is running on a desired node
\n\n$ kubectl get po feature-dependent-pod -o wide\nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nfeature-dependent-pod 1/1 Running 0 23s 10.36.0.4 node-2 <none> <none>\n
You can reach us via the following channels:
\n\nThis is a\nSIG-node\nsubproject, hosted under the\nKubernetes SIGs organization in Github.\nThe project was established in 2016 and was migrated to Kubernetes SIGs in 2018.
\n\nThis is open source software released under the Apache 2.0 License.
\n","dir":"/contributing/","name":"index.md","path":"contributing/index.md","url":"/contributing/"},{"title":"Worker cmdline reference","layout":"default","sort":3,"content":"To quickly view available command line flags execute nfd-worker -help
.\nIn a docker container:
docker run k8s.gcr.io/nfd/node-feature-discovery:v0.9.0 nfd-worker -help\n
Print usage and exit.
\n\nPrint version and exit.
\n\nThe -config
flag specifies the path of the nfd-worker configuration file to\nuse.
Default: /etc/kubernetes/node-feature-discovery/nfd-worker.conf
\n\nExample:
\n\nnfd-worker -config=/opt/nfd/worker.conf\n
The -options
flag may be used to specify and override configuration file\noptions directly from the command line. The required format is the same as in\nthe config file i.e. JSON or YAML. Configuration options specified via this\nflag will override those from the configuration file:
Default: empty
\n\nExample:
\n\nnfd-worker -options='{\"sources\":{\"cpu\":{\"cpuid\":{\"attributeWhitelist\":[\"AVX\",\"AVX2\"]}}}}'\n
The -server
flag specifies the address of the nfd-master endpoint where to\nconnect to.
Default: localhost:8080
\n\nExample:
\n\nnfd-worker -server=nfd-master.nfd.svc.cluster.local:443\n
The -ca-file
is one of the three flags (together with -cert-file
and\n-key-file
) controlling the mutual TLS authentication on the worker side.\nThis flag specifies the TLS root certificate that is used for verifying the\nauthenticity of nfd-master.
Default: empty
\n\nNote: Must be specified together with -cert-file
and -key-file
Example:
\n\nnfd-worker -ca-file=/opt/nfd/ca.crt -cert-file=/opt/nfd/worker.crt -key-file=/opt/nfd/worker.key\n
The -cert-file
is one of the three flags (together with -ca-file
and\n-key-file
) controlling mutual TLS authentication on the worker side. This\nflag specifies the TLS certificate presented for authenticating outgoing\nrequests.
Default: empty
\n\nNote: Must be specified together with -ca-file
and -key-file
Example:
\n\nnfd-workerr -cert-file=/opt/nfd/worker.crt -key-file=/opt/nfd/worker.key -ca-file=/opt/nfd/ca.crt\n
The -key-file
is one of the three flags (together with -ca-file
and\n-cert-file
) controlling the mutual TLS authentication on the worker side.\nThis flag specifies the private key corresponding the given certificate file\n(-cert-file
) that is used for authenticating outgoing requests.
Default: empty
\n\nNote: Must be specified together with -cert-file
and -ca-file
Example:
\n\nnfd-worker -key-file=/opt/nfd/worker.key -cert-file=/opt/nfd/worker.crt -ca-file=/opt/nfd/ca.crt\n
The -server-name-override
flag specifies the common name (CN) which to\nexpect from the nfd-master TLS certificate. This flag is mostly intended for\ndevelopment and debugging purposes.
Default: empty
\n\nExample:
\n\nnfd-worker -server-name-override=localhost\n
The -sources
flag specifies a comma-separated list of enabled feature\nsources. A special value all
enables all feature sources.
Note: This flag takes precedence over the core.sources
configuration\nfile option.
Default: all
\n\nExample:
\n\nnfd-worker -sources=kernel,system,local\n
DEPRECATED: you should use the core.sources
option in the\nconfiguration file, instead.
The -no-publish
flag disables all communication with the nfd-master, making\nit a “dry-run” flag for nfd-worker. NFD-Worker runs feature detection normally,\nbut no labeling requests are sent to nfd-master.
Default: false
\n\nExample:
\n\nnfd-worker -no-publish\n
The -label-whitelist
specifies a regular expression for filtering feature\nlabels based on their name. Each label must match against the given reqular\nexpression in order to be published.
Note: The regular expression is only matches against the “basename” part of the\nlabel, i.e. to the part of the name after ‘/’. The label namespace is omitted.
\n\nNote: This flag takes precedence over the core.labelWhiteList
configuration\nfile option.
Default: empty
\n\nExample:
\n\nnfd-worker -label-whitelist='.*cpuid\\.'\n
DEPRECATED: you should use the core.labelWhiteList
option in the\nconfiguration file, instead.
The -oneshot
flag causes nfd-worker to exit after one pass of feature\ndetection.
Default: false
\n\nExample:
\n\nnfd-worker -oneshot -no-publish\n
The -sleep-interval
specifies the interval between feature re-detection (and\nnode re-labeling). A non-positive value implies infinite sleep interval, i.e.\nno re-detection or re-labeling is done.
Note: This flag takes precedence over the core.sleepInterval
configuration\nfile option.
Default: 60s
\n\nExample:
\n\nnfd-worker -sleep-interval=1h\n
DEPRECATED: you should use the core.sleepInterval
option in the\nconfiguration file, instead.
The following logging-related flags are inherited from the\nklog package.
\n\nNote: The logger setup can also be specified via the core.klog
configuration\nfile options. However, the command line flags take precedence over any\ncorresponding config file options specified.
If true, adds the file directory to the header of the log messages.
\n\nDefault: false
\n\nLog to standard error as well as files.
\n\nDefault: false
\n\nWhen logging hits line file:N, emit a stack trace.
\n\nDefault: empty
\n\nIf non-empty, write log files in this directory.
\n\nDefault: empty
\n\nIf non-empty, use this log file.
\n\nDefault: empty
\n\nDefines the maximum size a log file can grow to. Unit is megabytes. If the\nvalue is 0, the maximum file size is unlimited.
\n\nDefault: 1800
\n\nLog to standard error instead of files
\n\nDefault: true
\n\nIf true, avoid header prefixes in the log messages.
\n\nDefault: false
\n\nIf true, avoid headers when opening log files.
\n\nDefault: false
\n\nLogs at or above this threshold go to stderr.
\n\nDefault: 2
\n\nNumber for the log level verbosity.
\n\nDefault: 0
\n\nComma-separated list of pattern=N
settings for file-filtered logging.
Default: empty
\n","dir":"/advanced/","name":"worker-commandline-reference.md","path":"advanced/worker-commandline-reference.md","url":"/advanced/worker-commandline-reference.html"},{"title":"Deployment and usage","layout":"default","sort":3,"content":"NFD currently offers two variants of the container image. The “full” variant is\ncurrently deployed by default.
\n\nThis image is based on\ndebian:buster-slim and contains a full Linux\nsystem for running shell-based nfd-worker hooks and doing live debugging and\ndiagnosis of the NFD images.
\n\nThis is a minimal image based on\ngcr.io/distroless/base\nand only supports running statically linked binaries.
\n\nThe container image tag has suffix -minimal
\n(e.g. k8s.gcr.io/nfd/node-feature-discovery:v0.9.0-minimal
)
Deployment using the\nNode Feature Discovery Operator\nis recommended to be done via\noperatorhub.io.
\n\nInstall the operator:
\n\n kubectl create -f https://operatorhub.io/install/nfd-operator.yaml\n
Create NodeFeatureDiscovery resource (in nfd
namespace here):
cat << EOF | kubectl apply -f -\n apiVersion: v1\n kind: Namespace\n metadata:\n name: nfd\n ---\n apiVersion: nfd.kubernetes.io/v1alpha1\n kind: NodeFeatureDiscovery\n metadata:\n name: my-nfd-deployment\n namespace: nfd\n EOF\n
In order to deploy the minimal image you need to add
\n\n image: k8s.gcr.io/nfd/node-feature-discovery:v0.9.0-minimal\n
to the metadata of NodeFeatureDiscovery object above.
\n\nThe kustomize overlays provided in the repo can be used directly:
\n\nkubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref=v0.9.0\n
This will required RBAC rules and deploy nfd-master (as a deployment) and\nnfd-worker (as a daemonset) in the node-feature-discovery
namespace.
Alternatively you can clone the repository and customize the deployment by\ncreating your own overlays. For example, to deploy the minimal\nimage. See kustomize for more information about managing\ndeployment configurations.
\n\nThe NFD repository hosts a set of overlays for different usages and deployment\nscenarios under\ndeployment/overlays
default
:\ndefault deployment of nfd-worker as a daemonset, descibed abovedefault-combined
\nsee Master-worker pod belowdefault-job
:\nsee Worker one-shot belowprune
:\nclean up the cluster after uninstallation, see\nRemoving feature labelssamples/cert-manager
:\nan example for supplementing the default deployment with cert-manager for TLS\nauthentication, see\nAutomated TLS certificate management using cert-manager\nfor detailssamples/custom-rules
:\nan example for spicing up the default deployment with a separately managed\nconfigmap of custom labeling rules, see\nCustom feature source for more information about\ncustom node labelsYou can also run nfd-master and nfd-worker inside the same pod
\n\nkubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default-combined?ref=v0.9.0\n\n
This creates a DaemonSet runs both nfd-worker and nfd-master in the same Pod.\nIn this case no nfd-master is run on the master node(s), but, the worker nodes\nare able to label themselves which may be desirable e.g. in single-node setups.
\n\nFeature discovery can alternatively be configured as a one-shot job.\nThe default-job
overlay may be used to achieve this:
NUM_NODES=$(kubectl get no -o jsonpath='{.items[*].metadata.name}' | wc -w)\nkubectl kustomize https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default-job?ref=v0.9.0 | \\\n sed s\"/NUM_NODES/$NUM_NODES/\" | \\\n kubectl apply -f -\n
The example above launces as many jobs as there are non-master nodes. Note that\nthis approach does not guarantee running once on every node. For example,\ntainted, non-ready nodes or some other reasons in Job scheduling may cause some\nnode(s) will run extra job instance(s) to satisfy the request.
\n\nNode Feature Discovery Helm chart allow to easily deploy and manage NFD.
\n\nHelm package manager should be installed.
\n\nTo install the latest stable version:
\n\nexport NFD_NS=node-feature-discovery\nhelm repo add nfd https://kubernetes-sigs.github.io/node-feature-discovery/charts\nhelm repo update\nhelm install nfd/node-feature-discovery --namespace $NFD_NS --create-namespace --generate-name\n
To install the latest development version you need to clone the NFD Git\nrepository and install from there.
\n\ngit clone https://github.com/kubernetes-sigs/node-feature-discovery/\ncd node-feature-discovery/deployment/helm\nexport NFD_NS=node-feature-discovery\nhelm install node-feature-discovery ./node-feature-discovery/ --namespace $NFD_NS --create-namespace\n
See the configuration section below for instructions how to\nalter the deployment parameters.
\n\nIn order to deploy the minimal image you need to override the image\ntag:
\n\nhelm install node-feature-discovery ./node-feature-discovery/ --set image.tag=v0.9.0-minimal --namespace $NFD_NS --create-namespace\n
You can override values from values.yaml
and provide a file with custom values:
export NFD_NS=node-feature-discovery\nhelm install nfd/node-feature-discovery -f <path/to/custom/values.yaml> --namespace $NFD_NS --create-namespace\n
To specify each parameter separately you can provide them to helm install command:
\n\nexport NFD_NS=node-feature-discovery\nhelm install nfd/node-feature-discovery --set nameOverride=NFDinstance --set master.replicaCount=2 --namespace $NFD_NS --create-namespace\n
To uninstall the node-feature-discovery
deployment:
export NFD_NS=node-feature-discovery\nhelm uninstall node-feature-discovery --namespace $NFD_NS\n
The command removes all the Kubernetes components associated with the chart and\ndeletes the release.
\n\nIn order to tailor the deployment of the Node Feature Discovery to your cluster needs\nWe have introduced the following Chart parameters.
\n\nName | \nType | \nDefault | \ndescription | \n
---|---|---|---|
image.repository | \n string | \nk8s.gcr.io/nfd/node-feature-discovery | \n NFD image repository | \n
image.tag | \n string | \nv0.9.0 | \n NFD image tag | \n
image.pullPolicy | \n string | \nAlways | \n Image pull policy | \n
imagePullSecrets | \n list | \n[] | \nImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info | \n
serviceAccount.create | \n bool | \ntrue | \nSpecifies whether a service account should be created | \n
serviceAccount.annotations | \n dict | \n{} | \nAnnotations to add to the service account | \n
serviceAccount.name | \n string | \n\n | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | \n
rbac | \n dict | \n\n | RBAC parameteres | \n
nameOverride | \n string | \n\n | Override the name of the chart | \n
fullnameOverride | \n string | \n\n | Override a default fully qualified app name | \n
Name | \nType | \nDefault | \ndescription | \n
---|---|---|---|
master.* | \n dict | \n\n | NFD master deployment configuration | \n
master.instance | \n string | \n\n | Instance name. Used to separate annotation namespaces for multiple parallel deployments | \n
master.extraLabelNs | \n array | \n[] | \nList of allowed extra label namespaces | \n
master.replicaCount | \n integer | \n1 | \nNumber of desired pods. This is a pointer to distinguish between explicit zero and not specified | \n
master.podSecurityContext | \n dict | \n{} | \nSecurityContext holds pod-level security attributes and common container settings | \n
master.service.type | \n string | \nClusterIP | \nNFD master service type | \n
master.service.port | \n integer | \nport | \nNFD master service port | \n
master.resources | \n dict | \n{} | \nNFD master pod resources management | \n
master.nodeSelector | \n dict | \n{} | \nNFD master pod node selector | \n
master.tolerations | \n dict | \nScheduling to master node is disabled | \nNFD master pod tolerations | \n
master.annotations | \n dict | \n{} | \nNFD master pod metadata | \n
master.affinity | \n dict | \n\n | NFD master pod required node affinity | \n
Name | \nType | \nDefault | \ndescription | \n
---|---|---|---|
worker.* | \n dict | \n\n | NFD master daemonset configuration | \n
worker.configmapName | \n string | \nnfd-worker-conf | \n NFD worker pod ConfigMap name | \n
worker.config | \n string | \n`` | \nNFD worker service configuration | \n
worker.podSecurityContext | \n dict | \n{} | \nSecurityContext holds pod-level security attributes and common container settings | \n
worker.securityContext | \n dict | \n{} | \nContainer security settings | \n
worker.resources | \n dict | \n{} | \nNFD worker pod resources management | \n
worker.nodeSelector | \n dict | \n{} | \nNFD worker pod node selector | \n
worker.tolerations | \n dict | \n{} | \nNFD worker pod node tolerations | \n
worker.annotations | \n dict | \n{} | \nNFD worker pod metadata | \n
If you want to use the latest development version (master branch) you need to\nbuild your own custom image.\nSee the Developer Guide for instructions how to\nbuild images and deploy them on your cluster.
\n\nNFD-Master runs as a deployment (with a replica count of 1), by default\nit prefers running on the cluster’s master nodes but will run on worker\nnodes if no master nodes are found.
\n\nFor High Availability, you should simply increase the replica count of\nthe deployment object. You should also look into adding\ninter-pod\naffinity to prevent masters from running on the same node.\nHowever note that inter-pod affinity is costly and is not recommended\nin bigger clusters.
\n\nNFD-Master listens for connections from nfd-worker(s) and connects to the\nKubernetes API server to add node labels advertised by them.
\n\nIf you have RBAC authorization enabled (as is the default e.g. with clusters\ninitialized with kubeadm) you need to configure the appropriate ClusterRoles,\nClusterRoleBindings and a ServiceAccount in order for NFD to create node\nlabels. The provided template will configure these for you.
\n\nNFD-Worker is preferably run as a Kubernetes DaemonSet. This assures\nre-labeling on regular intervals capturing changes in the system configuration\nand makes sure that new nodes are labeled as they are added to the cluster.\nWorker connects to the nfd-master service to advertise hardware features.
\n\nWhen run as a daemonset, nodes are re-labeled at an default interval of 60s.\nThis can be changed by using the\ncore.sleepInterval
\nconfig option (or\n-sleep-interval
\ncommand line flag).
The worker configuration file is watched and re-read on every change which\nprovides a simple mechanism of dynamic run-time reconfiguration. See\nworker configuration for more details.
\n\nNFD supports mutual TLS authentication between the nfd-master and nfd-worker\ninstances. That is, nfd-worker and nfd-master both verify that the other end\npresents a valid certificate.
\n\nTLS authentication is enabled by specifying -ca-file
, -key-file
and\n-cert-file
args, on both the nfd-master and nfd-worker instances.\nThe template specs provided with NFD contain (commented out) example\nconfiguration for enabling TLS authentication.
The Common Name (CN) of the nfd-master certificate must match the DNS name of\nthe nfd-master Service of the cluster. By default, nfd-master only check that\nthe nfd-worker has been signed by the specified root certificate (-ca-file).\nAdditional hardening can be enabled by specifying -verify-node-name in\nnfd-master args, in which case nfd-master verifies that the NodeName presented\nby nfd-worker matches the Common Name (CN) or a Subject Alternative Name (SAN)\nof its certificate.
\n\ncert-manager can be used to automate certificate\nmanagement between nfd-master and the nfd-worker pods.
\n\nNFD source code repository contains an example kustomize overlay that can be\nused to deploy NFD with cert-manager supplied certificates enabled. The\ninstructions below describe steps how to generate a self-signed CA certificate\nand set up cert-manager’s\nCA Issuer to sign\nCertificate
requests for NFD components in node-feature-discovery
\nnamespace.
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.yaml\nopenssl genrsa -out deployment/overlays/samples/cert-manager/tls.key 2048\nopenssl req -x509 -new -nodes -key deployment/overlays/samples/cert-manager/tls.key -subj \"/CN=nfd-ca\" \\\n -days 10000 -out deployment/overlays/samples/cert-manager/tls.crt\nkubectl apply -k deployment/overlays/samples/cert-manager\n
NFD-Worker supports dynamic configuration through a configuration file. The\ndefault location is /etc/kubernetes/node-feature-discovery/nfd-worker.conf
,\nbut, this can be changed by specifying the-config
command line flag.\nConfiguration file is re-read whenever it is modified which makes run-time\nre-configuration of nfd-worker straightforward.
Worker configuration file is read inside the container, and thus, Volumes and\nVolumeMounts are needed to make your configuration available for NFD. The\npreferred method is to use a ConfigMap which provides easy deployment and\nre-configurability.
\n\nThe provided nfd-worker deployment templates create an empty configmap and\nmount it inside the nfd-worker containers. Configuration can be edited with:
\n\nkubectl -n ${NFD_NS} edit configmap nfd-worker-conf\n
See\nnfd-worker configuration file reference\nfor more details.\nThe (empty-by-default)\nexample config\ncontains all available configuration options and can be used as a reference\nfor creating creating a configuration.
\n\nConfiguration options can also be specified via the -options
command line\nflag, in which case no mounts need to be used. The same format as in the config\nfile must be used, i.e. JSON (or YAML). For example:
-options='{\"sources\": { \"pci\": { \"deviceClassWhitelist\": [\"12\"] } } }'\n
Configuration options specified from the command line will override those read\nfrom the config file.
\n\nNodes with specific features can be targeted using the nodeSelector
field. The\nfollowing example shows how to target nodes with Intel TurboBoost enabled.
apiVersion: v1\nkind: Pod\nmetadata:\n labels:\n env: test\n name: golang-test\nspec:\n containers:\n - image: golang\n name: go1\n nodeSelector:\n feature.node.kubernetes.io/cpu-pstate.turbo: 'true'\n
For more details on targeting nodes, see\nnode selection.
\n\nIf you followed the deployment instructions above you can simply do:
\n\nkubectl -n nfd delete NodeFeatureDiscovery my-nfd-deployment\n
Optionally, you can also remove the namespace:
\n\nkubectl delete ns nfd\n
See the node-feature-discovery-operator and OLM project\ndocumentation for instructions for uninstalling the operator and operator\nlifecycle manager, respectively.
\n\nSimplest way is to invoke kubectl delete
on the deployment files you used.\nBeware that this will also delete the namespace that NFD is running in. For\nexample, in case the default deployment from the repo was used:
\nkubectl delete -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/default?ref=v0.9.0\n
Alternatively you can delete create objects one-by-one, depending on the type\nof deployment, for example:
\n\nNFD_NS=node-feature-discovery\nkubectl -n $NFD_NS delete ds nfd-worker\nkubectl -n $NFD_NS delete deploy nfd-master\nkubectl -n $NFD_NS delete svc nfd-master\nkubectl -n $NFD_NS delete sa nfd-master\nkubectl delete clusterrole nfd-master\nkubectl delete clusterrolebinding nfd-master\n
NFD-Master has a special -prune
command line flag for removing all\nnfd-related node labels, annotations and extended resources from the cluster.
kubectl apply -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/prune?ref=v0.9.0\nkubectl -n node-feature-discovery wait job.batch/nfd-prune --for=condition=complete && \\\n kubectl delete -k https://github.com/kubernetes-sigs/node-feature-discovery/deployment/overlays/prune?ref=v0.9.0\n
NOTE: You must run prune before removing the RBAC rules (serviceaccount,\nclusterrole and clusterrolebinding).
\n\n\n","dir":"/get-started/","name":"deployment-and-usage.md","path":"get-started/deployment-and-usage.md","url":"/get-started/deployment-and-usage.html"},{"title":"Feature discovery","layout":"default","sort":4,"content":"Feature discovery in nfd-worker is performed by a set of separate modules\ncalled feature sources. Most of them are specifically responsible for certain\ndomain of features (e.g. cpu). In addition there are two highly customizable\nfeature sources that work accross the system.
\n\nEach discovered feature is advertised a label in the Kubernetes Node object.\nThe published node labels encode a few pieces of information:
\n\nfeature.node.kubernetes.io
feature.node.kubernetes.io
and its sub-namespaces (e.g.\nvendor.profile.node.kubernetes.io
) are allowed by default--extra-label-ns
\ncommand line flag of nfd-mastercpu
).cpuid.AESNI
from cpu).Feature label names adhere to the following pattern:
\n\n<namespace>/<source name>-<feature name>[.<attribute name>]\n
The last component (i.e. attribute-name
) is optional, and only used if a\nfeature logically has sub-hierarchy, e.g. sriov.capable
and\nsriov.configure
from the network
source.
The -sources
flag controls which sources to use for discovery.
Note: Consecutive runs of nfd-worker will update the labels on a\ngiven node. If features are not discovered on a consecutive run, the corresponding\nlabel will be removed. This includes any restrictions placed on the consecutive run,\nsuch as restricting discovered features with the -label-whitelist option.
\n\nThe cpu feature source supports the following labels:
\n\nFeature name | \nAttribute | \nDescription | \n
---|---|---|
cpuid | \n<cpuid flag> | \nCPU capability is supported | \n
hardware_multithreading | \n\n | Hardware multithreading, such as Intel HTT, enabled (number of logical CPUs is greater than physical CPUs) | \n
power | \nsst_bf.enabled | \nIntel SST-BF (Intel Speed Select Technology - Base frequency) enabled | \n
pstate | \nstatus | \nThe status of the Intel pstate driver when in use and enabled, either ‘active’ or ‘passive’. | \n
\n | turbo | \nSet to ‘true’ if turbo frequencies are enabled in Intel pstate driver, set to ‘false’ if they have been disabled. | \n
\n | scaling_governor | \nThe value of the Intel pstate scaling_governor when in use, either ‘powersave’ or ‘performance’. | \n
cstate | \nenabled | \nSet to ‘true’ if cstates are set in the intel_idle driver, otherwise set to ‘false’. Unset if intel_idle cpuidle driver is not active. | \n
rdt | \nRDTMON | \nIntel RDT Monitoring Technology | \n
\n | RDTCMT | \nIntel Cache Monitoring (CMT) | \n
\n | RDTMBM | \nIntel Memory Bandwidth Monitoring (MBM) | \n
\n | RDTL3CA | \nIntel L3 Cache Allocation Technology | \n
\n | RDTL2CA | \nIntel L2 Cache Allocation Technology | \n
\n | RDTMBA | \nIntel Memory Bandwidth Allocation (MBA) Technology | \n
The (sub-)set of CPUID attributes to publish is configurable via the\nattributeBlacklist
and attributeWhitelist
cpuid options of the cpu source.\nIf whitelist is specified, only whitelisted attributes will be published. With\nblacklist, only blacklisted attributes are filtered out. attributeWhitelist
\nhas priority over attributeBlacklist
. For examples and more information\nabout configurability, see\nconfiguration.\nBy default, the following CPUID flags have been blacklisted:\nBMI1, BMI2, CLMUL, CMOV, CX16, ERMS, F16C, HTT, LZCNT, MMX, MMXEXT, NX, POPCNT,\nRDRAND, RDSEED, RDTSCP, SGX, SSE, SSE2, SSE3, SSE4, SSE42 and SSSE3.
NOTE The cpuid features advertise supported CPU capabilities, that is, a\ncapability might be supported but not enabled.
\n\nAttribute | \nDescription | \n
---|---|
ADX | \nMulti-Precision Add-Carry Instruction Extensions (ADX) | \n
AESNI | \nAdvanced Encryption Standard (AES) New Instructions (AES-NI) | \n
AVX | \nAdvanced Vector Extensions (AVX) | \n
AVX2 | \nAdvanced Vector Extensions 2 (AVX2) | \n
See the full list in github.com/klauspost/cpuid.
\n\nAttribute | \nDescription | \n
---|---|
IDIVA | \nInteger divide instructions available in ARM mode | \n
IDIVT | \nInteger divide instructions available in Thumb mode | \n
THUMB | \nThumb instructions | \n
FASTMUL | \nFast multiplication | \n
VFP | \nVector floating point instruction extension (VFP) | \n
VFPv3 | \nVector floating point extension v3 | \n
VFPv4 | \nVector floating point extension v4 | \n
VFPD32 | \nVFP with 32 D-registers | \n
HALF | \nHalf-word loads and stores | \n
EDSP | \nDSP extensions | \n
NEON | \nNEON SIMD instructions | \n
LPAE | \nLarge Physical Address Extensions | \n
Attribute | \nDescription | \n
---|---|
AES | \nAnnouncing the Advanced Encryption Standard | \n
EVSTRM | \nEvent Stream Frequency Features | \n
FPHP | \nHalf Precision(16bit) Floating Point Data Processing Instructions | \n
ASIMDHP | \nHalf Precision(16bit) Asimd Data Processing Instructions | \n
ATOMICS | \nAtomic Instructions to the A64 | \n
ASIMRDM | \nSupport for Rounding Double Multiply Add/Subtract | \n
PMULL | \nOptional Cryptographic and CRC32 Instructions | \n
JSCVT | \nPerform Conversion to Match Javascript | \n
DCPOP | \nPersistent Memory Support | \n
The Custom feature source allows the user to define features based on a mix of\npredefined rules. A rule is provided input witch affects its process of\nmatching for a defined feature. The rules are specified in the\nnfd-worker configuration file. See\nconfiguration for instructions\nand examples how to set-up and manage the worker configuration.
\n\nTo aid in making Custom Features clearer, we define a general and a per rule\nnomenclature, keeping things as consistent as possible.
\n\nAdditionally to the rules defined in the nfd-worker configuration file, the\nCustom feature can read more configuration files located in the\n/etc/kubernetes/node-feature-discovery/custom.d/
directory. This makes more\ndynamic and flexible configuration easier. This directory must be available\ninside the NFD worker container, so Volumes and VolumeMounts must be used for\nmounting e.g. ConfigMap(s). The example deployment manifests provide an example\n(commented out) for providing Custom configuration with an additional\nConfigMap, mounted into the custom.d
directory.
Rule :Represents a matching logic that is used to match on a feature.\nRule Input :The input a Rule is provided. This determines how a Rule performs the match operation.\nMatcher :A composition of Rules, each Matcher may be composed of at most one instance of each Rule.\n
Rules are specified under sources.custom
in the nfd-worker configuration\nfile.
sources:\n custom:\n - name: <feature name>\n value: <optional feature value, defaults to \"true\">\n matchOn:\n - <Rule-1>: <Rule-1 Input>\n [<Rule-2>: <Rule-2 Input>]\n - <Matcher-2>\n - ...\n - ...\n - <Matcher-N>\n - <custom feature 2>\n - ...\n - ...\n - <custom feature M>\n
Specifying Rules to match on a feature is done by providing a list of Matchers.\nEach Matcher contains one or more Rules.
\n\nLogical OR is performed between Matchers and logical AND is performed\nbetween Rules of a given Matcher.
\n\nAttribute :A PCI attribute.\nElement :An identifier of the PCI attribute.\n
The PciId Rule allows matching the PCI devices in the system on the following\nAttributes: class
,vendor
and device
. A list of Elements is provided for\neach Attribute.
pciId :\n class: [<class id>, ...]\n vendor: [<vendor id>, ...]\n device: [<device id>, ...]\n
Matching is done by performing a logical OR between Elements of an Attribute\nand logical AND between the specified Attributes for each PCI device in the\nsystem. At least one Attribute must be specified. Missing attributes will not\npartake in the matching process.
\n\nAttribute :A USB attribute.\nElement :An identifier of the USB attribute.\n
The UsbId Rule allows matching the USB devices in the system on the following\nAttributes: class
,vendor
, device
and serial
. A list of Elements is\nprovided for each Attribute.
usbId :\n class: [<class id>, ...]\n vendor: [<vendor id>, ...]\n device: [<device id>, ...]\n serial: [<serial>, ...]\n
Matching is done by performing a logical OR between Elements of an Attribute\nand logical AND between the specified Attributes for each USB device in the\nsystem. At least one Attribute must be specified. Missing attributes will not\npartake in the matching process.
\n\nElement :A kernel module\n
The LoadedKMod Rule allows matching the loaded kernel modules in the system\nagainst a provided list of Elements.
\n\nloadedKMod : [<kernel module>, ...]\n
Matching is done by performing logical AND for each provided Element, i.e\nthe Rule will match if all provided Elements (kernel modules) are loaded in the\nsystem.
\n\nElement :A CPUID flag\n
The Rule allows matching the available CPUID flags in the system against a\nprovided list of Elements.
\n\ncpuId : [<CPUID flag string>, ...]\n
Matching is done by performing logical AND for each provided Element, i.e the\nRule will match if all provided Elements (CPUID flag strings) are available in\nthe system.
\n\nElement :A Kconfig option\n
The Rule allows matching the kconfig options in the system against a provided\nlist of Elements.
\n\nkConfig: [<kernel config option ('y' or 'm') or '=<value>'>, ...]\n
Matching is done by performing logical AND for each provided Element, i.e the\nRule will match if all provided Elements (kernel config options) are enabled\n(y
or m
) or matching =<value>
in the kernel.
Element :A nodename regexp pattern\n
The Rule allows matching the node’s name against a provided list of Elements.
\n\nnodename: [ <nodename regexp pattern>, ... ]\n
Matching is done by performing logical OR for each provided Element, i.e the\nRule will match if one of the provided Elements (nodename regexp pattern)\nmatches the node’s name.
\n\ncustom:\n - name: \"my.kernel.feature\"\n matchOn:\n - loadedKMod: [\"kmod1\", \"kmod2\"]\n - name: \"my.pci.feature\"\n matchOn:\n - pciId:\n vendor: [\"15b3\"]\n device: [\"1014\", \"1017\"]\n - name: \"my.usb.feature\"\n matchOn:\n - usbId:\n vendor: [\"1d6b\"]\n device: [\"0003\"]\n serial: [\"090129a\"]\n - name: \"my.combined.feature\"\n matchOn:\n - loadedKMod : [\"vendor_kmod1\", \"vendor_kmod2\"]\n pciId:\n vendor: [\"15b3\"]\n device: [\"1014\", \"1017\"]\n - name: \"vendor.feature.node.kubernetes.io/accumulated.feature\"\n matchOn:\n - loadedKMod : [\"some_kmod1\", \"some_kmod2\"]\n - pciId:\n vendor: [\"15b3\"]\n device: [\"1014\", \"1017\"]\n - name: \"my.kernel.featureneedscpu\"\n matchOn:\n - kConfig: [\"KVM_INTEL\"]\n - cpuId: [\"VMX\"]\n - name: \"my.kernel.modulecompiler\"\n matchOn:\n - kConfig: [\"GCC_VERSION=100101\"]\n loadedKMod: [\"kmod1\"]\n - name: \"my.datacenter\"\n value: \"datacenter-1\"\n matchOn:\n - nodename: [ \"node-datacenter1-rack.*-server.*\" ]\n
In the example above:
\n\nfeature.node.kubernetes.io/custom-my.kernel.feature=true
if the node has\nkmod1
AND kmod2
kernel modules loaded.feature.node.kubernetes.io/custom-my.pci.feature=true
if the node contains\na PCI device with a PCI vendor ID of 15b3
AND PCI device ID of 1014
OR\n1017
.feature.node.kubernetes.io/custom-my.usb.feature=true
if the node contains\na USB device with a USB vendor ID of 1d6b
AND USB device ID of 0003
.feature.node.kubernetes.io/custom-my.combined.feature=true
if\nvendor_kmod1
AND vendor_kmod2
kernel modules are loaded AND the node\ncontains a PCI device\nwith a PCI vendor ID of 15b3
AND PCI device ID of 1014
or 1017
.vendor.feature.node.kubernetes.io/accumulated.feature=true
if\nsome_kmod1
AND some_kmod2
kernel modules are loaded OR the node\ncontains a PCI device\nwith a PCI vendor ID of 15b3
AND PCI device ID of 1014
OR 1017
.feature.node.kubernetes.io/custom-my.kernel.featureneedscpu=true
if\nKVM_INTEL
kernel config is enabled AND the node CPU supports VMX
\nvirtual machine extensionsfeature.node.kubernetes.io/custom-my.kernel.modulecompiler=true
if the\nin-tree kmod1
kernel module is loaded AND it’s built with\nGCC_VERSION=100101
.feature.node.kubernetes.io/my.datacenter=datacenter-1
if the node’s name\nmatches the node-datacenter1-rack.*-server.*
pattern, e.g.\nnode-datacenter1-rack2-server42
Some feature labels which are common and generic are defined statically in the\ncustom
feature source. A user may add additional Matchers to these feature\nlabels by defining them in the nfd-worker
configuration file.
Feature | \nAttribute | \nDescription | \n
---|---|---|
rdma | \ncapable | \nThe node has an RDMA capable Network adapter | \n
rdma | \nenabled | \nThe node has the needed RDMA modules loaded to run RDMA traffic | \n
The iommu feature source supports the following labels:
\n\nFeature name | \nDescription | \n
---|---|
enabled | \nIOMMU is present and enabled in the kernel | \n
The kernel feature source supports the following labels:
\n\nFeature | \nAttribute | \nDescription | \n
---|---|---|
config | \n<option name> | \nKernel config option is enabled (set ‘y’ or ‘m’). Default options are NO_HZ , NO_HZ_IDLE , NO_HZ_FULL and PREEMPT | \n
selinux | \nenabled | \nSelinux is enabled on the node | \n
version | \nfull | \nFull kernel version as reported by /proc/sys/kernel/osrelease (e.g. ‘4.5.6-7-g123abcde’) | \n
\n | major | \nFirst component of the kernel version (e.g. ‘4’) | \n
\n | minor | \nSecond component of the kernel version (e.g. ‘5’) | \n
\n | revision | \nThird component of the kernel version (e.g. ‘6’) | \n
Kernel config file to use, and, the set of config options to be detected are\nconfigurable. See configuration\nfor more information.
\n\nThe memory feature source supports the following labels:
\n\nFeature | \nAttribute | \nDescription | \n
---|---|---|
numa | \n\n | Multiple memory nodes i.e. NUMA architecture detected | \n
nv | \npresent | \nNVDIMM device(s) are present | \n
nv | \ndax | \nNVDIMM region(s) configured in DAX mode are present | \n
The network feature source supports the following labels:
\n\nFeature | \nAttribute | \nDescription | \n
---|---|---|
sriov | \ncapable | \nSingle Root Input/Output Virtualization (SR-IOV) enabled Network Interface Card(s) present | \n
\n | configured | \nSR-IOV virtual functions have been configured | \n
The pci feature source supports the following labels:
\n\nFeature | \nAttribute | \nDescription | \n
---|---|---|
<device label> | \npresent | \nPCI device is detected | \n
<device label> | \nsriov.capable | \nSingle Root Input/Output Virtualization (SR-IOV) enabled PCI device present | \n
<device label>
is composed of raw PCI IDs, separated by underscores. The set\nof fields used in <device label>
is configurable, valid fields being class
,\nvendor
, device
, subsystem_vendor
and subsystem_device
. Defaults are\nclass
and vendor
. An example label using the default label fields:
feature.node.kubernetes.io/pci-1200_8086.present=true\n
Also the set of PCI device classes that the feature source detects is\nconfigurable. By default, device classes (0x)03, (0x)0b40 and (0x)12, i.e.\nGPUs, co-processors and accelerator cards are detected.
\n\nThe usb feature source supports the following labels:
\n\nFeature | \nAttribute | \nDescription | \n
---|---|---|
<device label> | \npresent | \nUSB device is detected | \n
<device label>
is composed of raw USB IDs, separated by underscores. The set\nof fields used in <device label>
is configurable, valid fields being class
,\nvendor
, device
and serial
. Defaults are class
, vendor
and device
.\nAn example label using the default label fields:
feature.node.kubernetes.io/usb-fe_1a6e_089a.present=true\n
See configuration for more\ninformation on NFD config.
\n\nThe storage feature source supports the following labels:
\n\nFeature name | \nDescription | \n
---|---|
nonrotationaldisk | \nNon-rotational disk, like SSD, is present in the node | \n
The system feature source supports the following labels:
\n\nFeature | \nAttribute | \nDescription | \n
---|---|---|
os_release | \nID | \nOperating system identifier | \n
\n | VERSION_ID | \nOperating system version identifier (e.g. ‘6.7’) | \n
\n | VERSION_ID.major | \nFirst component of the OS version id (e.g. ‘6’) | \n
\n | VERSION_ID.minor | \nSecond component of the OS version id (e.g. ‘7’) | \n
NFD has a special feature source named local which is designed for getting\nthe labels from user-specific feature detector. It provides a mechanism for\nusers to implement custom feature sources in a pluggable way, without modifying\nnfd source code or Docker images. The local feature source can be used to\nadvertise new user-specific features, and, for overriding labels created by the\nother feature sources.
\n\nThe local feature source gets its labels by two different ways:
\n\n/etc/kubernetes/node-feature-discovery/source.d/
directory. The hook files\nmust be executable and they are supposed to print all discovered features in\nstdout
, one per line. With ELF binaries static linking is recommended as\nthe selection of system libraries available in the NFD release image is very\nlimited. Other runtimes currently supported by the NFD stock image are bash\nand perl./etc/kubernetes/node-feature-discovery/features.d/
directory. The file\ncontent is expected to be similar to the hook output (described above).NOTE: The minimal image variant only\nsupports running statically linked binaries.
\n\nThese directories must be available inside the Docker image so Volumes and\nVolumeMounts must be used if standard NFD images are used. The given template\nfiles mount by default the source.d
and the features.d
directories\nrespectively from /etc/kubernetes/node-feature-discovery/source.d/
and\n/etc/kubernetes/node-feature-discovery/features.d/
from the host. You should\nupdate them to match your needs.
In both cases, the labels can be binary or non binary, using either <name>
or\n<name>=<value>
format.
Unlike the other feature sources, the name of the file, instead of the name of\nthe feature source (that would be local
in this case), is used as a prefix in\nthe label name, normally. However, if the <name>
of the label starts with a\nslash (/
) it is used as the label name as is, without any additional prefix.\nThis makes it possible for the user to fully control the feature label names,\ne.g. for overriding labels created by other feature sources.
You can also override the default namespace of your labels using this format:\n<namespace>/<name>[=<value>]
. If using something else than\n[<sub-ns>.]feature.node.kubernetes.io
, you must whitelist your namespace\nusing the -extra-label-ns
option on the master.\nIn this case, the name of the\nfile will not be added to the label name. For example, if you want to add the\nlabel my.namespace.org/my-label=value
, your hook output or file must contains\nmy.namespace.org/my-label=value
and you must add\n-extra-label-ns=my.namespace.org
on the master command line.
stderr
output of the hooks is propagated to NFD log so it can be used for\ndebugging and logging.
One use case for the hooks and/or feature files is detecting features in other\nPods outside NFD, e.g. in Kubernetes device plugins. It is possible to mount\nthe source.d
and/or features.d
directories common with the NFD Pod and\ndeploy the custom hooks/features there. NFD will periodically scan the\ndirectories and run any hooks and read any feature files it finds. The\ndefault deployments contain hostPath
mounts for sources.d
and features.d
\ndirectories. By using the same mounts in the secondary Pod (e.g. device plugin)\nyou have created a shared area for delivering hooks and feature files to NFD.
User has a shell script\n/etc/kubernetes/node-feature-discovery/source.d/my-source
which has the\nfollowing stdout
output:
MY_FEATURE_1\nMY_FEATURE_2=myvalue\n/override_source-OVERRIDE_BOOL\n/override_source-OVERRIDE_VALUE=123\noverride.namespace/value=456\n
which, in turn, will translate into the following node labels:
\n\nfeature.node.kubernetes.io/my-source-MY_FEATURE_1=true\nfeature.node.kubernetes.io/my-source-MY_FEATURE_2=myvalue\nfeature.node.kubernetes.io/override_source-OVERRIDE_BOOL=true\nfeature.node.kubernetes.io/override_source-OVERRIDE_VALUE=123\noverride.namespace/value=456\n
User has a file /etc/kubernetes/node-feature-discovery/features.d/my-source
\nwhich contains the following lines:
MY_FEATURE_1\nMY_FEATURE_2=myvalue\n/override_source-OVERRIDE_BOOL\n/override_source-OVERRIDE_VALUE=123\noverride.namespace/value=456\n
which, in turn, will translate into the following node labels:
\n\nfeature.node.kubernetes.io/my-source-MY_FEATURE_1=true\nfeature.node.kubernetes.io/my-source-MY_FEATURE_2=myvalue\nfeature.node.kubernetes.io/override_source-OVERRIDE_BOOL=true\nfeature.node.kubernetes.io/override_source-OVERRIDE_VALUE=123\noverride.namespace/value=456\n
NFD tries to run any regular files found from the hooks directory. Any\nadditional data files your hook might need (e.g. a configuration file) should\nbe placed in a separate directory in order to avoid NFD unnecessarily trying to\nexecute these. You can use a subdirectory under the hooks directory, for\nexample /etc/kubernetes/node-feature-discovery/source.d/conf/
.
NOTE! NFD will blindly run any executables placed/mounted in the hooks\ndirectory. It is the user’s responsibility to review the hooks for e.g.\npossible security implications.
\n\nNOTE! Be careful when creating and/or updating hook or feature files while\nNFD is running. In order to avoid race conditions you should write into a\ntemporary file (outside the source.d
and features.d
directories), and,\natomically create/update the original file by doing a filesystem move\noperation.
This feature is experimental and by no means a replacement for the usage of\ndevice plugins.
\n\nLabels which have integer values, can be promoted to Kubernetes extended\nresources by listing them to the master -resource-labels
command line flag.\nThese labels won’t then show in the node label section, they will appear only\nas extended resources.
An example use-case for the extended resources could be based on a hook which\ncreates a label for the node SGX EPC memory section size. By giving the name of\nthat label in the -resource-labels
flag, that value will then turn into an\nextended resource of the node, allowing PODs to request that resource and the\nKubernetes scheduler to schedule such PODs to only those nodes which have a\nsufficient capacity of said resource left.
Similar to labels, the default namespace feature.node.kubernetes.io
is\nautomatically prefixed to the extended resource, if the promoted label doesn’t\nhave a namespace.
Example usage of the command line arguments, using a new namespace:\nnfd-master -resource-labels=my_source-my.feature,sgx.some.ns/epc -extra-label-ns=sgx.some.ns
The above would result in following extended resources provided that related\nlabels exist:
\n\n sgx.some.ns/epc: <label value>\n feature.node.kubernetes.io/my_source-my.feature: <label value>\n
See the\nsample configuration file\nfor a full example configuration.
\n\nThe core
section contains common configuration settings that are not specific\nto any particular feature source.
core.sleepInterval
specifies the interval between consecutive passes of\nfeature (re-)detection, and thus also the interval between node re-labeling. A\nnon-positive value implies infinite sleep interval, i.e. no re-detection or\nre-labeling is done.
Note: Overridden by the deprecated --sleep-interval
command line flag (if\nspecified).
Default: 60s
Example:
\n\ncore:\n sleepInterval: 60s\n
core.sources
specifies the list of enabled feature sources. A special value\nall
enables all feature sources.
Note: Overridden by the deprecated --sources
command line flag (if\nspecified).
Default: [all]
Example:
\n\ncore:\n sources:\n - system\n - custom\n
core.labelWhiteList
specifies a regular expression for filtering feature\nlabels based on the label name. Non-matching labels are not published.
Note: The regular expression is only matches against the “basename” part of the\nlabel, i.e. to the part of the name after ‘/’. The label prefix (or namespace)\nis omitted.
\n\nNote: Overridden by the deprecated --label-whitelist
command line flag (if\nspecified).
Default: null
Example:
\n\ncore:\n labelWhiteList: '^cpu-cpuid'\n
Setting core.noPublish
to true
disables all communication with the\nnfd-master. It is effectively a “dry-run” flag: nfd-worker runs feature\ndetection normally, but no labeling requests are sent to nfd-master.
Note: Overridden by the --no-publish
command line flag (if specified).
Default: false
Example:
\n\ncore:\n noPublish: true\n
The following options specify the logger configuration. Most of which can be\ndynamically adjusted at run-time.
\n\nNote: The logger options can also be specified via command line flags which\ntake precedence over any corresponding config file options.
\n\nIf true, adds the file directory to the header of the log messages.
\n\nDefault: false
Run-time configurable: yes
\n\nLog to standard error as well as files.
\n\nDefault: false
Run-time configurable: yes
\n\nWhen logging hits line file:N, emit a stack trace.
\n\nDefault: empty
\n\nRun-time configurable: yes
\n\nIf non-empty, write log files in this directory.
\n\nDefault: empty
\n\nRun-time configurable: no
\n\nIf non-empty, use this log file.
\n\nDefault: empty
\n\nRun-time configurable: no
\n\nDefines the maximum size a log file can grow to. Unit is megabytes. If the\nvalue is 0, the maximum file size is unlimited.
\n\nDefault: 1800
Run-time configurable: no
\n\nLog to standard error instead of files
\n\nDefault: true
Run-time configurable: yes
\n\nIf true, avoid header prefixes in the log messages.
\n\nDefault: false
Run-time configurable: yes
\n\nIf true, avoid headers when opening log files.
\n\nDefault: false
Run-time configurable: no
\n\nLogs at or above this threshold go to stderr (default 2)
\n\nRun-time configurable: yes
\n\nNumber for the log level verbosity.
\n\nDefault: 0
Run-time configurable: yes
\n\nComma-separated list of pattern=N
settings for file-filtered logging.
Default: empty
\n\nRun-time configurable: yes
\n\nThe sources
section contains feature source specific configuration parameters.
Prevent publishing cpuid features listed in this option.
\n\nNote: overridden by sources.cpu.cpuid.attributeWhitelist
(if specified)
Default: [BMI1, BMI2, CLMUL, CMOV, CX16, ERMS, F16C, HTT, LZCNT, MMX, MMXEXT,\nNX, POPCNT, RDRAND, RDSEED, RDTSCP, SGX, SGXLC, SSE, SSE2, SSE3, SSE4.1,\nSSE4.2, SSSE3]
Example:
\n\nsources:\n cpu:\n cpuid:\n attributeBlacklist: [MMX, MMXEXT]\n
Only publish the cpuid features listed in this option.
\n\nNote: takes precedence over sources.cpu.cpuid.attributeBlacklist
Default: empty
\n\nExample:
\n\nsources:\n cpu:\n cpuid:\n attributeWhitelist: [AVX512BW, AVX512CD, AVX512DQ, AVX512F, AVX512VL]\n
Path of the kernel config file. If empty, NFD runs a search in the well-known\nstandard locations.
\n\nDefault: empty
\n\nExample:
\n\nsources:\n kernel:\n kconfigFile: \"/path/to/kconfig\"\n
Kernel configuration options to publish as feature labels.
\n\nDefault: [NO_HZ, NO_HZ_IDLE, NO_HZ_FULL, PREEMPT]
Example:
\n\nsources:\n kernel:\n configOpts: [NO_HZ, X86, DMI]\n
List of PCI device class IDs for which to\npublish a label. Can be specified as a main class only (e.g. 03
) or full\nclass-subclass combination (e.g. 0300
) - the former implies that all\nsubclasses are accepted. The format of the labels can be further configured\nwith deviceLabelFields.
Default: [\"03\", \"0b40\", \"12\"]
Example:
\n\nsources:\n pci:\n deviceClassWhitelist: [\"0200\", \"03\"]\n
The set of PCI ID fields to use when constructing the name of the feature\nlabel. Valid fields are class
, vendor
, device
, subsystem_vendor
and\nsubsystem_device
.
Default: [class, vendor]
Example:
\n\nsources:\n pci:\n deviceLabelFields: [class, vendor, device]\n
With the example config above NFD would publish labels like:\nfeature.node.kubernetes.io/pci-<class-id>_<vendor-id>_<device-id>.present=true
List of USB device class IDs for\nwhich to publish a feature label. The format of the labels can be further\nconfigured with deviceLabelFields.
\n\nDefault: [\"0e\", \"ef\", \"fe\", \"ff\"]
Example:
\n\nsources:\n usb:\n deviceClassWhitelist: [\"ef\", \"ff\"]\n
The set of USB ID fields from which to compose the name of the feature label.\nValid fields are class
, vendor
, device
and serial
.
Default: [class, vendor, device]
Example:
\n\nsources:\n pci:\n deviceLabelFields: [class, vendor]\n
With the example config above NFD would publish labels like:\nfeature.node.kubernetes.io/usb-<class-id>_<vendor-id>.present=true
List of rules to process in the custom feature source to create user-specific\nlabels. Refer to the documentation of the\ncustom feature source for details of\nthe available rules and their configuration.
\n\nDefault: empty
\n\nExample:
\n\nsource:\n custom:\n - name: \"my.custom.feature\"\n matchOn:\n - loadedKMod: [\"e1000e\"]\n - pciId:\n class: [\"0200\"]\n vendor: [\"8086\"]\n
This page contains usage examples and demos.
\n\nA demo on the benefits of using node feature discovery can be found in the\nsource code repository under\ndemo/.
\n","dir":"/get-started/","name":"examples-and-demos.md","path":"get-started/examples-and-demos.md","url":"/get-started/examples-and-demos.html"}]