[{"title":"Introduction","layout":"default","sort":1,"content":"

Introduction

\n\n

Table of Contents

\n\n
    \n
  1. NFD-Master
  2. \n
  3. NFD-Worker
  4. \n
  5. Feature Discovery
  6. \n
  7. Node Annotations
  8. \n
\n\n
\n\n

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\n

NFD consists of two software components:

\n\n
    \n
  1. nfd-master
  2. \n
  3. nfd-worker
  4. \n
\n\n

NFD-Master

\n\n

NFD-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\n

NFD-Worker

\n\n

NFD-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\n

Feature Discovery

\n\n

Feature discovery is divided into domain-specific feature sources:

\n\n\n\n

Each 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.

\n\n

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
\n\n

Node Annotations

\n\n

NFD also annotates nodes it is running on:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
AnnotationDescription
nfd.node.kubernetes.io/master.versionVersion of the nfd-master instance running on the node. Informative use only.
nfd.node.kubernetes.io/worker.versionVersion of the nfd-worker instance running on the node. Informative use only.
nfd.node.kubernetes.io/feature-labelsComma-separated list of node labels managed by NFD. NFD uses this internally so must not be edited by users.
nfd.node.kubernetes.io/extended-resourcesComma-separated list of node extended resources managed by NFD. NFD uses this internally so must not be edited by users.
\n\n

Unapplicable annotations are not created, i.e. for example master.version is only 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":"

Node Feature Discovery

\n\n

Welcome to Node Feature Discovery – a Kubernetes add-on for detecting hardware\nfeatures and system configuration!

\n\n

Continue to:

\n\n\n\n

Quick-start – the short-short version

\n\n
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-master.yaml.template\n  namespace/node-feature-discovery created\n...\n\n$ kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-worker-daemonset.yaml.template\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
\n","dir":"/get-started/","name":"index.md","path":"get-started/index.md","url":"/get-started/"},{"title":"Developer Guide","layout":"default","sort":1,"content":"

Developer Guide

\n\n

Table of contents

\n\n
    \n
  1. Building from Source
      \n
    1. Download the source code
    2. \n
    3. Docker Build
    4. \n
    5. Deployment
    6. \n
    7. Building Locally
    8. \n
    9. Customizing the Build
    10. \n
    11. Testing
    12. \n
    \n
  2. \n
  3. Running Locally
      \n
    1. NFD-Master
    2. \n
    3. NFD-Worker
    4. \n
    \n
  4. \n
  5. Documentation
  6. \n
\n\n
\n\n

Building from Source

\n\n

Download the source code

\n\n
git clone https://github.com/kubernetes-sigs/node-feature-discovery\ncd node-feature-discovery\n
\n\n

Docker Build

\n\n

Build the container image

\n\n

See customizing the build below for altering the\ncontainer image registry, for example.

\n\n
make\n
\n\n

Push the container image

\n

Optional, this example with Docker.

\n\n
docker push <IMAGE_TAG>\n
\n\n

Change the job spec to use your custom image (optional)

\n\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>]).

\n\n

Deployment

\n\n

The yamls makefile generates deployment specs matching your locally built\nimage. See build customization below for\nconfigurability, e.g. changing the deployment namespace.

\n\n
K8S_NAMESPACE=my-ns make yamls\nkubectl apply -f nfd-master.yaml\nkubectl apply -f nfd-worker-daemonset.yaml\n
\n\n

Alternatively, deploying worker and master in the same pod:

\n\n
K8S_NAMESPACE=my-ns make yamls\nkubectl apply -f nfd-master.yaml\nkubectl apply -f nfd-daemonset-combined.yaml\n
\n\n

Or worker as a one-shot job:

\n\n
K8S_NAMESPACE=my-ns make yamls\nkubectl apply -f nfd-master.yaml\nNUM_NODES=$(kubectl get no -o jsonpath='{.items[*].metadata.name}' | wc -w)\nsed s\"/NUM_NODES/$NUM_NODES/\" nfd-worker-job.yaml | kubectl apply -f -\n
\n\n

Building Locally

\n\n

You can also build the binaries locally

\n\n
make build\n
\n\n

This will compile binaries under bin/

\n\n

Customizing the Build

\n\n

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\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
VariableDescriptionDefault value
HOSTMOUNT_PREFIXPrefix of system directories for feature discovery (local builds)/ (local builds) /host- (container builds)
IMAGE_BUILD_CMDCommand to build the imagedocker build
IMAGE_BUILD_EXTRA_OPTSExtra options to pass to build commandempty
IMAGE_PUSH_CMDCommand to push the image to remote registrydocker push
IMAGE_REGISTRYContainer image registry to usek8s.gcr.io/nfd
IMAGE_TAG_NAMEContainer image tag name<nfd version>
IMAGE_EXTRA_TAG_NAMESAdditional container image tag(s) to create when building imageempty
K8S_NAMESPACEnfd-master and nfd-worker namespacekube-system
KUBECONFIGKubeconfig for running e2e-testsempty
E2E_TEST_CONFIGParameterization file of e2e-tests (see example)empty
\n\n

For example, to use a custom registry:

\n\n
make IMAGE_REGISTRY=<my custom registry uri>\n
\n\n

Or to specify a build tool different from Docker, It can be done in 2 ways:

\n\n
    \n
  1. via environment\n
    IMAGE_BUILD_CMD=\"buildah bud\" make\n
    \n
  2. \n
  3. by overriding the variable value\n
    make  IMAGE_BUILD_CMD=\"buildah bud\"\n
    \n
  4. \n
\n\n

Testing

\n\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\n
make test\n
\n\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\n
make e2e-test KUBECONFIG=$HOME/.kube/config\n
\n\n

Running Locally

\n\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\n

NFD-Master

\n\n

When 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.

\n\n
$ export NFD_CONTAINER_IMAGE=gcr.io/k8s-staging-nfd/node-feature-discovery:master\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
\n\n

Command line flags of nfd-master:

\n\n
$ docker run --rm ${NFD_CONTAINER_IMAGE} nfd-master --help\n...\nUsage:\n  nfd-master [--prune] [--no-publish] [--label-whitelist=<pattern>] [--port=<port>]\n     [--ca-file=<path>] [--cert-file=<path>] [--key-file=<path>]\n     [--verify-node-name] [--extra-label-ns=<list>] [--resource-labels=<list>]\n     [--kubeconfig=<path>]\n  nfd-master -h | --help\n  nfd-master --version\n\n  Options:\n  -h --help                       Show this screen.\n  --version                       Output version and exit.\n  --prune                         Prune all NFD related attributes from all nodes\n                                  of the cluster and exit.\n  --kubeconfig=<path>             Kubeconfig to use [Default: ]\n  --port=<port>                   Port on which to listen for connections.\n                                  [Default: 8080]\n  --ca-file=<path>                Root certificate for verifying connections\n                                  [Default: ]\n  --cert-file=<path>              Certificate used for authenticating connections\n                                  [Default: ]\n  --key-file=<path>               Private key matching --cert-file\n                                  [Default: ]\n  --verify-node-name              Verify worker node name against CN from the TLS\n                                  certificate. Only has effect when TLS authentication\n                                  has been enabled.\n  --no-publish                    Do not publish feature labels\n  --label-whitelist=<pattern>     Regular expression to filter label names to\n                                  publish to the Kubernetes API server.\n                                  NB: the label namespace is omitted i.e. the filter\n                                  is only applied to the name part after '/'.\n                                  [Default: ]\n  --extra-label-ns=<list>         Comma separated list of allowed extra label namespaces\n                                  [Default: ]\n  --resource-labels=<list>        Comma separated list of labels to be exposed as extended resources.\n                                  [Default: ]\n
\n\n

NFD-Worker

\n\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
\n\n

If you just want to try out feature discovery without connecting to nfd-master,\npass the --no-publish flag to nfd-worker.

\n\n

Command line flags of nfd-worker:

\n\n
$ docker run --rm ${NFD_CONTAINER_IMAGE} nfd-worker --help\n...\nnfd-worker.\n\n  Usage:\n  nfd-worker [--no-publish] [--sources=<sources>] [--label-whitelist=<pattern>]\n     [--oneshot | --sleep-interval=<seconds>] [--config=<path>]\n     [--options=<config>] [--server=<server>] [--server-name-override=<name>]\n     [--ca-file=<path>] [--cert-file=<path>] [--key-file=<path>]\n  nfd-worker -h | --help\n  nfd-worker --version\n\n  Options:\n  -h --help                   Show this screen.\n  --version                   Output version and exit.\n  --config=<path>             Config file to use.\n                              [Default: /etc/kubernetes/node-feature-discovery/nfd-worker.conf]\n  --options=<config>          Specify config options from command line. Config\n                              options are specified in the same format as in the\n                              config file (i.e. json or yaml). These options\n                              will override settings read from the config file.\n                              [Default: ]\n  --ca-file=<path>            Root certificate for verifying connections\n                              [Default: ]\n  --cert-file=<path>          Certificate used for authenticating connections\n                              [Default: ]\n  --key-file=<path>           Private key matching --cert-file\n                              [Default: ]\n  --server=<server>           NFD server address to connecto to.\n                              [Default: localhost:8080]\n  --server-name-override=<name> Name (CN) expect from server certificate, useful\n                              in testing\n                              [Default: ]\n  --sources=<sources>         Comma separated list of feature sources.\n                              [Default: cpu,custom,iommu,kernel,local,memory,network,pci,storage,system,usb]\n  --no-publish                Do not publish discovered features to the\n                              cluster-local Kubernetes API server.\n  --label-whitelist=<pattern> Regular expression to filter label names to\n                              publish to the Kubernetes API server.\n                              NB: the label namespace is omitted i.e. the filter\n                              is only applied to the name part after '/'.\n                              [Default: ]\n  --oneshot                   Label once and exit.\n  --sleep-interval=<seconds>  Time to sleep between re-labeling. Non-positive\n                              value implies no re-labeling (i.e. infinite\n                              sleep). [Default: 60s]\n
\n\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\ntemplate spec\nfor up-to-date information about the required volume mounts.

\n\n

Documentation

\n\n

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\n

Building the documentation is containerized in order to fix the build\nenvironment. The recommended way for developing documentation is to run:

\n\n
make site-serve\n
\n\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.

\n\n

In order to just build the html documentation run:

\n\n
make site-build\n
\n\n

This will generate html documentation under docs/_site/.

\n\n\n","dir":"/advanced/","name":"developer-guide.md","path":"advanced/developer-guide.md","url":"/advanced/developer-guide.html"},{"title":"Advanced","layout":"default","sort":2,"content":"

Advanced

\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":"

NFD-Master Commandline Flags

\n\n

Table of Contents

\n\n
    \n
  1. -h, –help
  2. \n
  3. –version
  4. \n
  5. –prune
  6. \n
  7. –port
  8. \n
  9. –ca-file
  10. \n
  11. –cert-file
  12. \n
  13. –key-file
  14. \n
  15. –verify-node-name
  16. \n
  17. –no-publish
  18. \n
  19. –label-whitelist
  20. \n
  21. –extra-label-ns
  22. \n
  23. –resource-labels
  24. \n
\n\n
\n\n

To quickly view available command line flags execute nfd-master --help.\nIn a docker container:

\n\n
docker run gcr.io/k8s-staging-nfd/node-feature-discovery:master nfd-master --help\n
\n\n

-h, –help

\n\n

Print usage and exit.

\n\n

–version

\n\n

Print version and exit.

\n\n

–prune

\n\n

The --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.

\n\n

–port

\n\n

The --port flag specifies the TCP port that nfd-master listens for incoming requests.

\n\n

Default: 8080

\n\n

Example:

\n\n
nfd-master --port=443\n
\n\n

–ca-file

\n\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.

\n\n

Default: empty

\n\n

Note: Must be specified together with --cert-file and --key-file

\n\n

Example:

\n\n
nfd-master --ca-file=/opt/nfd/ca.crt --cert-file=/opt/nfd/master.crt --key-file=/opt/nfd/master.key\n
\n\n

–cert-file

\n\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.

\n\n

Default: empty

\n\n

Note: Must be specified together with --ca-file and --key-file

\n\n

Example:

\n\n
nfd-master --cert-file=/opt/nfd/master.crt --key-file=/opt/nfd/master.key --ca-file=/opt/nfd/ca.crt\n
\n\n

–key-file

\n\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.

\n\n

Default: empty

\n\n

Note: Must be specified together with --cert-file and --ca-file

\n\n

Example:

\n\n
nfd-master --key-file=/opt/nfd/master.key --cert-file=/opt/nfd/master.crt --ca-file=/opt/nfd/ca.crt\n
\n\n

–verify-node-name

\n\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 in its TLS certificate. Thus,\nworkers are only able to label the node they are running on (or the node whose\ncertificate they present), and, each worker must have an individual\ncertificate.

\n\n

Node Name based authorization is disabled by default and thus it is possible\nfor all nfd-worker pods in the cluster to use one shared certificate, making\nNFD deployment much easier.

\n\n

Default: false

\n\n

Example:

\n\n
nfd-master --verify-node-name --ca-file=/opt/nfd/ca.crt \\\n    --cert-file=/opt/nfd/master.crt --key-file=/opt/nfd/master.key\n
\n\n

–no-publish

\n\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.

\n\n

Default: false

\n\n

Example:

\n\n
nfd-master --no-publish\n
\n\n

–label-whitelist

\n\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.

\n\n

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\n

Default: empty

\n\n

Example:

\n\n
nfd-master --label-whitelist='.*cpuid\\.'\n
\n\n

–extra-label-ns

\n\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. This option can be used\nto allow vendor-specific namespaces for custom labels from the local and custom\nfeature sources.

\n\n

The same namespace control and this flag applies Extended Resources (created\nwith --resource-labels), too.

\n\n

Default: empty

\n\n

Example:

\n\n
nfd-master --extra-label-ns=vendor-1.com,vendor-2.io\n
\n\n

–resource-labels

\n\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.

\n\n

Default: empty

\n\n

Example:

\n\n
nfd-master --resource-labels=vendor-1.com/feature-1,vendor-2.io/feature-2\n
\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":"

Quick Start

\n\n

Minimal steps to deploy latest released version of NFD in your cluster.

\n\n

Installation

\n\n

Deploy nfd-master – creates a new namespace, service and required RBAC rules

\n\n
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-master.yaml.template\n
\n\n

Deploy nfd-worker as a daemonset

\n\n
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-worker-daemonset.yaml.template\n
\n\n

Verify

\n\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
\n\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
\n\n

Use Node Labels

\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
\n\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
\n","dir":"/get-started/","name":"quick-start.md","path":"get-started/quick-start.md","url":"/get-started/quick-start.html"},{"title":"Contributing","layout":"default","sort":3,"content":"

Contributing

\n\n
\n\n

Community

\n\n

You can reach us via the following channels:

\n\n\n\n

Governance

\n\n

This 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\n

License

\n\n

This 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":"

NFD-Worker Commandline Flags

\n\n

Table of Contents

\n\n
    \n
  1. -h, –help
  2. \n
  3. –version
  4. \n
  5. –config
  6. \n
  7. –options
  8. \n
  9. –server
  10. \n
  11. –ca-file
  12. \n
  13. –cert-file
  14. \n
  15. –key-file
  16. \n
  17. –server-name-override
  18. \n
  19. –sources
  20. \n
  21. –no-publish
  22. \n
  23. –label-whitelist
  24. \n
  25. –oneshot
  26. \n
  27. –sleep-interval
  28. \n
\n\n
\n\n

To quickly view available command line flags execute nfd-worker --help.\nIn a docker container:

\n\n
docker run gcr.io/k8s-staging-nfd/node-feature-discovery:master nfd-worker --help\n
\n\n

-h, –help

\n\n

Print usage and exit.

\n\n

–version

\n\n

Print version and exit.

\n\n

–config

\n\n

The --config flag specifies the path of the nfd-worker configuration file to\nuse.

\n\n

Default: /etc/kubernetes/node-feature-discovery/nfd-worker.conf

\n\n

Example:

\n\n
nfd-worker --config=/opt/nfd/worker.conf\n
\n\n

–options

\n\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:

\n\n

Default: empty

\n\n

Example:

\n\n
nfd-worker --options='{\"sources\":{\"cpu\":{\"cpuid\":{\"attributeWhitelist\":[\"AVX\",\"AVX2\"]}}}}'\n
\n\n

–server

\n\n

The --server flag specifies the address of the nfd-master endpoint where to\nconnect to.

\n\n

Default: localhost:8080

\n\n

Example:

\n\n
nfd-worker --server=nfd-master.nfd.svc.cluster.local:443\n
\n\n

–ca-file

\n\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.

\n\n

Default: empty

\n\n

Note: Must be specified together with --cert-file and --key-file

\n\n

Example:

\n\n
nfd-worker --ca-file=/opt/nfd/ca.crt --cert-file=/opt/nfd/worker.crt --key-file=/opt/nfd/worker.key\n
\n\n

–cert-file

\n\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.

\n\n

Default: empty

\n\n

Note: Must be specified together with --ca-file and --key-file

\n\n

Example:

\n\n
nfd-workerr --cert-file=/opt/nfd/worker.crt --key-file=/opt/nfd/worker.key --ca-file=/opt/nfd/ca.crt\n
\n\n

–key-file

\n\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.

\n\n

Default: empty

\n\n

Note: Must be specified together with --cert-file and --ca-file

\n\n

Example:

\n\n
nfd-worker --key-file=/opt/nfd/worker.key --cert-file=/opt/nfd/worker.crt --ca-file=/opt/nfd/ca.crt\n
\n\n

–server-name-override

\n\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.

\n\n

Default: empty

\n\n

Example:

\n\n
nfd-worker --server-name-override=localhost\n
\n\n

–sources

\n\n

The --sources flag specifies a comma-separated list of enabled feature\nsources.

\n\n

Default: cpu,custom,iommu,kernel,local,memory,network,pci,storage,system,usb

\n\n

Example:

\n\n
nfd-worker --sources=kernel,system,local\n
\n\n

–no-publish

\n\n

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.

\n\n

Default: false

\n\n

Example:

\n\n
nfd-worker --no-publish\n
\n\n

–label-whitelist

\n\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.

\n\n

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\n

Default: empty

\n\n

Example:

\n\n
nfd-worker --label-whitelist='.*cpuid\\.'\n
\n\n

–oneshot

\n\n

The --oneshot flag causes nfd-worker to exit after one pass of feature\ndetection.

\n\n

Default: false

\n\n

Example:

\n\n
nfd-worker --oneshot --no-publish\n
\n\n

–sleep-interval

\n\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.

\n\n

Default: 60s

\n\n

Example:

\n\n
nfd-worker --sleep-interval=1h\n
\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":"

Deployment and Usage

\n\n

Table of Contents

\n\n
    \n
  1. Requirements
  2. \n
  3. Deployment options
      \n
    1. Operator
    2. \n
    3. Deployment Templates
    4. \n
    5. Build Your Own
    6. \n
    \n
  4. \n
  5. Usage
      \n
    1. NFD-Master
    2. \n
    3. NFD-Worker
    4. \n
    5. TLS authentication
    6. \n
    \n
  6. \n
  7. Configuration
  8. \n
  9. Using Node Labels
  10. \n
  11. Uninstallation
      \n
    1. Operator Was Used for Deployment
    2. \n
    3. Manual
    4. \n
    5. Removing Feature Labels
    6. \n
    \n
  12. \n
\n\n
\n\n

Requirements

\n\n
    \n
  1. Linux (x86_64/Arm64/Arm)
  2. \n
  3. kubectl\n(properly set up and configured to work with your Kubernetes cluster)
  4. \n
\n\n

Deployment options

\n\n

Operator

\n\n

Deployment using the\nNode Feature Discovery Operator\nis recommended to be done via\noperatorhub.io.

\n\n
    \n
  1. You need to have\nOLM\ninstalled. If you don’t, take a look at the\nlatest release\nfor detailed instructions.
  2. \n
  3. Install the operator:\n
    kubectl create -f https://operatorhub.io/install/nfd-operator.yaml\n
    \n
  4. \n
  5. Create NodeFeatureDiscovery resource (in nfd namespace here):\n
    cat << EOF | kubectl apply -f -\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: nfd\n---\napiVersion: nfd.kubernetes.io/v1alpha1\nkind: NodeFeatureDiscovery\nmetadata:\n  name: my-nfd-deployment\n  namespace: nfd\nEOF\n
    \n
  6. \n
\n\n

Deployment Templates

\n\n

The template specs provided in the repo can be used directly:

\n\n
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-master.yaml.template\nkubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-worker-daemonset.yaml.template\n
\n\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.

\n\n

Alternatively you can download the templates and customize the deployment\nmanually.

\n\n

Master-Worker Pod

\n\n

You can also run nfd-master and nfd-worker inside the same pod

\n\n
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-daemonset-combined.yaml.template\n
\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\n

Worker One-shot

\n\n

Feature discovery can alternatively be configured as a one-shot job.\nThe Job template may be used to achieve this:

\n\n
NUM_NODES=$(kubectl get no -o jsonpath='{.items[*].metadata.name}' | wc -w)\ncurl -fs https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-worker-job.yaml.template | \\\n    sed s\"/NUM_NODES/$NUM_NODES/\" | \\\n    kubectl apply -f -\n
\n\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\n

Build Your Own

\n\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\n

Usage

\n\n

NFD-Master

\n\n

NFD-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\n

For 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\n

NFD-Master listens for connections from nfd-worker(s) and connects to the\nKubernetes API server to add node labels advertised by them.

\n\n

If 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\n

NFD-Worker

\n\n

NFD-Worker is preferably run as a Kubernetes DaemonSet. This assures\nre-labeling on regular intervals capturing changes in the system configuration\nand mames 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\n

When run as a daemonset, nodes are re-labeled at an interval specified using\nthe --sleep-interval option. In the\ntemplate\nthe default interval is set to 60s which is also the default when no\n--sleep-interval is specified. Also, the configuration file is re-read on\neach iteration providing a simple mechanism of run-time reconfiguration.

\n\n

TLS authentication

\n\n

NFD 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\n

TLS 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.

\n\n

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) of its certificate. This means that\neach nfd-worker requires a individual node-specific TLS certificate.

\n\n

Configuration

\n\n

NFD-Worker supports a configuration file. The default location is\n/etc/kubernetes/node-feature-discovery/nfd-worker.conf, but,\nthis can be changed by specifying the--config command line flag.\nConfiguration file is re-read on each labeling pass (determined by\n--sleep-interval) which makes run-time re-configuration of nfd-worker\npossible.

\n\n

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. For example, create a config map using the example config\nas a template:

\n\n
cp nfd-worker.conf.example nfd-worker.conf\nvim nfd-worker.conf  # edit the configuration\nkubectl create configmap nfd-worker-config --from-file=nfd-worker.conf\n
\n\n

Then, configure Volumes and VolumeMounts in the Pod spec (just the relevant\nsnippets shown below):

\n\n
...\n  containers:\n      volumeMounts:\n        - name: nfd-worker-config\n          mountPath: \"/etc/kubernetes/node-feature-discovery/\"\n...\n  volumes:\n    - name: nfd-worker-config\n      configMap:\n        name: nfd-worker-config\n...\n
\n\n

You could also use other types of volumes, of course. That is, hostPath if\ndifferent config for different nodes would be required, for example.

\n\n

The (empty-by-default)\nexample config\nis used as a config in the NFD Docker image. Thus, this can be used as a default\nconfiguration in custom-built images.

\n\n

Configuration 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:

\n\n
--options='{\"sources\": { \"pci\": { \"deviceClassWhitelist\": [\"12\"] } } }'\n
\n\n

Configuration options specified from the command line will override those read\nfrom the config file.

\n\n

Using Node Labels

\n\n

Nodes with specific features can be targeted using the nodeSelector field. The\nfollowing example shows how to target nodes with Intel TurboBoost enabled.

\n\n
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
\n\n

For more details on targeting nodes, see\nnode selection.

\n\n

Uninstallation

\n\n

Operator Was Used for Deployment

\n\n

If you followed the deployment instructions above you can simply do:

\n\n
kubectl -n nfd delete NodeFeatureDiscovery my-nfd-deployment\n
\n\n

Optionally, you can also remove the namespace:

\n\n
kubectl delete ns nfd\n
\n\n

See the node-feature-discovery-operator and OLM project\ndocumentation for instructions for uninstalling the operator and operator\nlifecycle manager, respectively.

\n\n

Manual

\n\n
NFD_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
\n\n

Removing Feature Labels

\n\n

NFD-Master has a special --prune command line flag for removing all\nnfd-related node labels, annotations and extended resources from the cluster.

\n\n
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/node-feature-discovery/master/nfd-prune.yaml.template\nkubectl -n node-feature-discovery wait job.batch/nfd-prune --for=condition=complete && \\\n    kubectl -n node-feature-discovery delete job/nfd-prune\n
\n\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

\n\n

Table of Contents

\n\n
    \n
  1. Feature labels
  2. \n
  3. Feature Sources
      \n
    1. CPU
    2. \n
    3. Custom
    4. \n
    5. IOMMU
    6. \n
    7. Kernel
    8. \n
    9. Memory
    10. \n
    11. Network
    12. \n
    13. PCI
    14. \n
    15. USB
    16. \n
    17. Storage
    18. \n
    19. System
    20. \n
    21. Local – User-specific Features
    22. \n
    \n
  4. \n
  5. Extended resources
  6. \n
\n\n
\n\n

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\n

Feature labels

\n\n

Each discovered feature is advertised a label in the Kubernetes Node object.\nThe published node labels encode a few pieces of information:

\n\n\n\n

Feature label names adhere to the following pattern:

\n\n
<namespace>/<source name>-<feature name>[.<attribute name>]\n
\n\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.

\n\n

The --sources flag controls which sources to use for discovery.

\n\n

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\n

Feature Sources

\n\n

CPU

\n\n

The cpu feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Feature nameAttributeDescription
cpuid<cpuid flag>CPU capability is supported
hardware_multithreading Hardware multithreading, such as Intel HTT, enabled (number of logical CPUs is greater than physical CPUs)
powersst_bf.enabledIntel SST-BF (Intel Speed Select Technology - Base frequency) enabled
pstateturboSet to ‘true’ if turbo frequencies are enabled in Intel pstate driver, set to ‘false’ if they have been disabled.
rdtRDTMONIntel RDT Monitoring Technology
 RDTCMTIntel Cache Monitoring (CMT)
 RDTMBMIntel Memory Bandwidth Monitoring (MBM)
 RDTL3CAIntel L3 Cache Allocation Technology
 RDTL2CAIntel L2 Cache Allocation Technology
 RDTMBAIntel Memory Bandwidth Allocation (MBA) Technology
\n\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 configuration.\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.1, SSE4.2 and SSSE3.

\n\n

NOTE The cpuid features advertise supported CPU capabilities, that is, a\ncapability might be supported but not enabled.

\n\n

X86 CPUID Attributes (Partial List)

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
AttributeDescription
ADXMulti-Precision Add-Carry Instruction Extensions (ADX)
AESNIAdvanced Encryption Standard (AES) New Instructions (AES-NI)
AVXAdvanced Vector Extensions (AVX)
AVX2Advanced Vector Extensions 2 (AVX2)
\n\n

Arm CPUID Attribute (Partial List)

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
AttributeDescription
IDIVAInteger divide instructions available in ARM mode
IDIVTInteger divide instructions available in Thumb mode
THUMBThumb instructions
FASTMULFast multiplication
VFPVector floating point instruction extension (VFP)
VFPv3Vector floating point extension v3
VFPv4Vector floating point extension v4
VFPD32VFP with 32 D-registers
HALFHalf-word loads and stores
EDSPDSP extensions
NEONNEON SIMD instructions
LPAELarge Physical Address Extensions
\n\n

Arm64 CPUID Attribute (Partial List)

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
AttributeDescription
AESAnnouncing the Advanced Encryption Standard
EVSTRMEvent Stream Frequency Features
FPHPHalf Precision(16bit) Floating Point Data Processing Instructions
ASIMDHPHalf Precision(16bit) Asimd Data Processing Instructions
ATOMICSAtomic Instructions to the A64
ASIMRDMSupport for Rounding Double Multiply Add/Subtract
PMULLOptional Cryptographic and CRC32 Instructions
JSCVTPerform Conversion to Match Javascript
DCPOPPersistent Memory Support
\n\n

Custom

\n\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.

\n\n

To aid in making Custom Features clearer, we define a general and a per rule\nnomenclature, keeping things as consistent as possible.

\n\n

General Nomenclature & Definitions

\n\n
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
\n\n

Custom Features Format (using the Nomenclature defined above)

\n\n
- name: <feature name>\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
\n\n

Matching process

\n\n

Specifying Rules to match on a feature is done by providing a list of Matchers.\nEach Matcher contains one or more Rules.

\n\n

Logical OR is performed between Matchers and logical AND is performed\nbetween Rules of a given Matcher.

\n\n

Rules

\n\n
PciId Rule
\n\n
Nomenclature
\n\n
Attribute   :A PCI attribute.\nElement     :An identifier of the PCI attribute.\n
\n\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.

\n\n
Format
\n\n
pciId :\n  class: [<class id>, ...]\n  vendor: [<vendor id>,  ...]\n  device: [<device id>, ...]\n
\n\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\n
UsbId Rule
\n\n
Nomenclature
\n\n
Attribute   :A USB attribute.\nElement     :An identifier of the USB attribute.\n
\n\n

The UsbId Rule allows matching the USB devices in the system on the following\nAttributes: class,vendor and device. A list of Elements is provided for\neach Attribute.

\n\n
Format
\n\n
usbId :\n  class: [<class id>, ...]\n  vendor: [<vendor id>,  ...]\n  device: [<device id>, ...]\n
\n\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\n
LoadedKMod Rule
\n\n
Nomenclature
\n\n
Element     :A kernel module\n
\n\n

The LoadedKMod Rule allows matching the loaded kernel modules in the system\nagainst a provided list of Elements.

\n\n
Format
\n\n
loadedKMod : [<kernel module>, ...]\n
\n\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\n
CpuId Rule
\n\n
Nomenclature
\n\n
Element     :A CPUID flag\n
\n\n

The Rule allows matching the available CPUID flags in the system against a\nprovided list of Elements.

\n\n
Format
\n\n
cpuId : [<CPUID flag string>, ...]\n
\n\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\n
Kconfig Rule
\n\n
Nomenclature
\n\n
Element     :A Kconfig option\n
\n\n

The Rule allows matching the kconfig options in the system against a provided\nlist of Elements.

\n\n
Format
\n\n
kConfig: [<kernel config option ('y' or 'm') or '=<value>'>, ...]\n
\n\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.

\n\n

Example

\n\n
custom:\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  - name: \"my.combined.feature\"\n    matchOn:\n      - loadedKMod : [\"vendor_kmod1\", \"vendor_kmod2\"]\n        pciId:\n          vendor: [\"15b3\"]\n          device: [\"1014\", \"1017\"]\n  - name: \"my.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
\n\n

In the example above:

\n\n\n\n

Statically defined features

\n\n

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.

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
FeatureAttributeDescription
rdmacapableThe node has an RDMA capable Network adapter
rdmaenabledThe node has the needed RDMA modules loaded to run RDMA traffic
\n\n

IOMMU

\n\n

The iommu feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n
Feature nameDescription
enabledIOMMU is present and enabled in the kernel
\n\n

Kernel

\n\n

The kernel feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
FeatureAttributeDescription
config<option name>Kernel config option is enabled (set ‘y’ or ‘m’).
Default options are NO_HZ, NO_HZ_IDLE, NO_HZ_FULL and PREEMPT
selinuxenabledSelinux is enabled on the node
versionfullFull kernel version as reported by /proc/sys/kernel/osrelease (e.g. ‘4.5.6-7-g123abcde’)
 majorFirst component of the kernel version (e.g. ‘4’)
 minorSecond component of the kernel version (e.g. ‘5’)
 revisionThird component of the kernel version (e.g. ‘6’)
\n\n

Kernel config file to use, and, the set of config options to be detected are\nconfigurable.\nSee configuration for\nmore information.

\n\n

Memory

\n\n

The memory feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
FeatureAttributeDescription
numa Multiple memory nodes i.e. NUMA architecture detected
nvpresentNVDIMM device(s) are present
nvdaxNVDIMM region(s) configured in DAX mode are present
\n\n

Network

\n\n

The network feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
FeatureAttributeDescription
sriovcapableSingle Root Input/Output Virtualization (SR-IOV) enabled Network Interface Card(s) present
 configuredSR-IOV virtual functions have been configured
\n\n

PCI

\n\n

The pci feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
FeatureAttributeDescription
<device label>presentPCI device is detected
<device label>sriov.capableSingle Root Input/Output Virtualization (SR-IOV) enabled PCI device present
\n\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:

\n\n
feature.node.kubernetes.io/pci-1200_8086.present=true\n
\n\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\n

USB

\n\n

The usb feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
FeatureAttributeDescription
<device label>presentUSB device is detected
\n\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, and device. Defaults are class, vendor and device. An\nexample label using the default label fields:

\n\n
feature.node.kubernetes.io/usb-fe_1a6e_089a.present=true\n
\n\n

See configuration for more information on NFD\nconfig.

\n\n

Storage

\n\n

The storage feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n
Feature nameDescription
nonrotationaldiskNon-rotational disk, like SSD, is present in the node
\n\n

System

\n\n

The system feature source supports the following labels:

\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
FeatureAttributeDescription
os_releaseIDOperating system identifier
 VERSION_IDOperating system version identifier (e.g. ‘6.7’)
 VERSION_ID.majorFirst component of the OS version id (e.g. ‘6’)
 VERSION_ID.minorSecond component of the OS version id (e.g. ‘7’)
\n\n

Local – User-specific Features

\n\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\n

The local feature source gets its labels by two different ways:

\n\n\n\n

These 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.

\n\n

In both cases, the labels can be binary or non binary, using either <name> or\n<name>=<value> format.

\n\n

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.

\n\n

You can also override the default namespace of your labels using this format:\n<namespace>/<name>[=<value>]. You must whitelist your namespace using the\n--extra-label-ns option on the master. In 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.

\n\n

stderr output of the hooks is propagated to NFD log so it can be used for\ndebugging and logging.

\n\n

Injecting Labels from Other Pods

\n\n

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\nexample nfd-worker deployment template\ncontains hostPath mounts for sources.d and features.d directories. By\nusing the same mounts in the secondary Pod (e.g. device plugin) you have\ncreated a shared area for delivering hooks and feature files to NFD.

\n\n

A Hook Example

\n\n

User has a shell script\n/etc/kubernetes/node-feature-discovery/source.d/my-source which has the\nfollowing stdout output:

\n\n
MY_FEATURE_1\nMY_FEATURE_2=myvalue\n/override_source-OVERRIDE_BOOL\n/override_source-OVERRIDE_VALUE=123\noverride.namespace/value=456\n
\n\n

which, in turn, will translate into the following node labels:

\n\n
feature.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
\n\n

A File Example

\n\n

User has a file /etc/kubernetes/node-feature-discovery/features.d/my-source\nwhich contains the following lines:

\n\n
MY_FEATURE_1\nMY_FEATURE_2=myvalue\n/override_source-OVERRIDE_BOOL\n/override_source-OVERRIDE_VALUE=123\noverride.namespace/value=456\n
\n\n

which, in turn, will translate into the following node labels:

\n\n
feature.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
\n\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/.

\n\n

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\n

NOTE! 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.

\n\n

Extended resources

\n\n

This feature is experimental and by no means a replacement for the usage of\ndevice plugins.

\n\n

Labels 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.

\n\n

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.

\n\n

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.

\n\n

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

\n\n

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
\n\n\n","dir":"/get-started/","name":"features.md","path":"get-started/features.md","url":"/get-started/features.html"},{"title":"Examples and Demos","layout":"default","sort":5,"content":"

Examples And Demos

\n\n

Table of Contents

\n\n
    \n
  1. Demos
      \n
    1. Usage demo
    2. \n
    3. Demo Use Case
    4. \n
    \n
  2. \n
\n\n
\n\n

This page contains usage examples and demos.

\n\n

Demos

\n\n

Usage demo

\n\n

\"asciicast\"

\n\n

Demo Use Case

\n\n

A 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"}]