1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00
Node feature discovery for Kubernetes
Find a file
2018-09-27 13:55:27 +03:00
demo Updated demo. 2016-11-17 11:15:32 -08:00
rdt-discovery Add install target to rdt-discovery Makefile 2018-09-24 10:15:23 +03:00
source Skip pstate detection on Arm 2018-08-17 11:10:18 +03:00
.dockerignore Added demo. 2016-09-30 13:10:05 -07:00
.gitignore Added demo. 2016-09-30 13:10:05 -07:00
.travis.yml Utilize multi-stage build to reduce docker image size 2018-09-24 10:15:23 +03:00
code-of-conduct.md Update code-of-conduct.md 2017-12-20 14:12:51 -05:00
CONTRIBUTING.md Template project files 2016-07-22 22:13:48 -07:00
Dockerfile Use Debian strecth-slim as a base for the producion Docker image 2018-09-24 10:15:23 +03:00
glide.lock Fix unit tests (#98) 2018-03-01 10:49:57 -08:00
glide.yaml Add support for Kubernetes 1.8+ (#82) 2017-11-21 12:21:56 +01:00
label-nodes.sh label-nodes.sh: match Ready without side-strings (#151) 2018-08-14 13:14:18 +03:00
LICENSE Template project files 2016-07-22 22:13:48 -07:00
main.go Implement detection of IOMMU (#136) (#137) 2018-07-24 08:24:45 -07:00
main_test.go Implement detection of IOMMU (#136) (#137) 2018-07-24 08:24:45 -07:00
Makefile Configurable image build tool 2018-09-20 09:28:28 +03:00
mockapihelpers.go Fix unit tests (#98) 2018-03-01 10:49:57 -08:00
mockfeaturesource.go Added tests. 2016-08-30 14:42:59 -07:00
node-feature-discovery-daemonset.json.template Update resource templates to use v0.3.0 2018-09-27 13:55:27 +03:00
node-feature-discovery-job.json.template Update resource templates to use v0.3.0 2018-09-27 13:55:27 +03:00
OWNERS Update owners file (#107) 2018-06-05 10:20:51 -07:00
rbac.yaml Add RBAC policy (#126) 2018-06-14 09:08:25 -07:00
README.md Update resource templates to use v0.3.0 2018-09-27 13:55:27 +03:00
RELEASE.md Added item to update :latest tag in quay.io 2016-12-07 14:30:22 -08:00

Node feature discovery for Kubernetes

Build Status Go Report Card

NOTE: We are gathering evidence in order to graduate from the Kubernetes incubator. If you are a user of the project, please add yourself to this list with as much detail as you are comfortable providing (name and email optional).

Overview

This software enables node feature discovery for Kubernetes. It detects hardware features available on each node in a Kubernetes cluster, and advertises those features using node labels.

This project uses GitHub milestones for release planning.

Command line interface

To try out stand-alone, one can run a Docker container where node-feature-discovery is already set as entry point. Such run is useful for checking features-detection part, but labeling part is expected to fail. It is recommended to use --no-publish and --oneshot to achieve clean run in stand-alone case.

node-feature-discovery.

  Usage:
  node-feature-discovery [--no-publish] [--sources=<sources>] [--label-whitelist=<pattern>]
     [--oneshot | --sleep-interval=<seconds>]
  node-feature-discovery -h | --help
  node-feature-discovery --version

  Options:
  -h --help                   Show this screen.
  --version                   Output version and exit.
  --sources=<sources>         Comma separated list of feature sources.
                              [Default: cpuid,iommu,memory,network,pstate,rdt,selinux,storage]
  --no-publish                Do not publish discovered features to the
                              cluster-local Kubernetes API server.
  --label-whitelist=<pattern> Regular expression to filter label names to
                              publish to the Kubernetes API server. [Default: ]
  --oneshot                   Label once and exit.
  --sleep-interval=<seconds>  Time to sleep between re-labeling. Non-positive
                              value implies no re-labeling (i.e. infinite
                              sleep). [Default: 60s]

NOTE Some feature sources need certain directories and/or files from the host mounted inside the NFD container. Thus, you need to provide Docker with the correct --volume options in order for them to work correctly when run stand-alone directly with docker run. See the template spec for up-to-date information about the required volume mounts.

Feature discovery

Feature sources

The current set of feature sources are the following:

Feature labels

The published node labels encode a few pieces of information:

  • A "namespace" (e.g. node.alpha.kubernetes-incubator.io/nfd).
  • The version of this discovery code that wrote the label, according to git describe --tags --dirty --always.
  • The source for each label (e.g. cpuid).
  • The name of the discovered feature as it appears in the underlying source, (e.g. AESNI from cpuid).

Note: only features that are available on a given node are labeled, so the only label value published for features is the string "true".

{
  "node.alpha.kubernetes-incubator.io/node-feature-discovery.version": "v0.3.0",
  "node.alpha.kubernetes-incubator.io/nfd-cpuid-<feature-name>": "true",
  "node.alpha.kubernetes-incubator.io/nfd-iommu-<feature-name>": "true",
  "node.alpha.kubernetes-incubator.io/nfd-memory-<feature-name>": "true",
  "node.alpha.kubernetes-incubator.io/nfd-network-<feature-name>": "true",
  "node.alpha.kubernetes-incubator.io/nfd-pstate-<feature-name>": "true",
  "node.alpha.kubernetes-incubator.io/nfd-rdt-<feature-name>": "true",
  "node.alpha.kubernetes-incubator.io/nfd-selinux-<feature-name>": "true",
  "node.alpha.kubernetes-incubator.io/nfd-storage-<feature-name>": "true"
}

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

Note: Consecutive runs of node-feature-discovery will update the labels on a given node. If features are not discovered on a consecutive run, the corresponding label will be removed. This includes any restrictions placed on the consecutive run, such as restricting discovered features with the --label-whitelist option.

X86 CPUID Features (Partial List)

Feature name Description
ADX Multi-Precision Add-Carry Instruction Extensions (ADX)
AESNI Advanced Encryption Standard (AES) New Instructions (AES-NI)
AVX Advanced Vector Extensions (AVX)
AVX2 Advanced Vector Extensions 2 (AVX2)
BMI1 Bit Manipulation Instruction Set 1 (BMI)
BMI2 Bit Manipulation Instruction Set 2 (BMI2)
SSE4.1 Streaming SIMD Extensions 4.1 (SSE4.1)
SSE4.2 Streaming SIMD Extensions 4.2 (SSE4.2)
SGX Software Guard Extensions (SGX)

Arm64 CPUID Features (Partial List)

Feature name Description
AES Announcing the Advanced Encryption Standard
EVSTRM Event Stream Frequency Features
FPHP Half Precision(16bit) Floating Point Data Processing Instructions
ASIMDHP Half Precision(16bit) Asimd Data Processing Instructions
ATOMICS Atomic Instructions to the A64
ASIMRDM Support for Rounding Double Multiply Add/Subtract
PMULL Optional Cryptographic and CRC32 Instructions
JSCVT Perform Conversion to Match Javascript
DCPOP Persistent Memory Support

IOMMU Features

Feature name Description
enabled IOMMU is present and enabled in the kernel

Memory Features

Feature name Description
numa Multiple memory nodes i.e. NUMA architecture detected

Network Features

Feature name Description
SRIOV Single Root Input/Output Virtualization (SR-IOV) enabled Network Interface Card

RDT (Intel Resource Director Technology) Features

Feature name Description
RDTMON Intel RDT Monitoring Technology
RDTCMT Intel Cache Monitoring (CMT)
RDTMBM Intel Memory Bandwidth Monitoring (MBM)
RDTL3CA Intel L3 Cache Allocation Technology
RDTL2CA Intel L2 Cache Allocation Technology
RDTMBA Intel Memory Bandwidth Allocation (MBA) Technology

Selinux Features

Feature name Description
selinux selinux is enabled on the node

Storage Features

Feature name Description
nonrotationaldisk Non-rotational disk, like SSD, is present in the node

Getting started

System requirements

  1. Linux (x86_64/Arm64)
  2. [kubectl] kubectl-setup (properly set up and configured to work with your Kubernetes cluster)
  3. [Docker] docker-down (only required to build and push docker images)

Usage

Feature discovery is preferably run as a Kubernetes DaemonSet. There is an example spec that can be used as a template, or, as is when just trying out the service:

kubectl create -f rbac.yaml
kubectl create -f node-feature-discovery-daemonset.json.template

When the job runs, it contacts the Kubernetes API server to add labels to the node to advertise hardware features.

If you have RBAC authorization enabled (as is the default e.g. with clusters initialized with kubeadm) you need to configure the appropriate ClusterRoles, ClusterRoleBindings and a ServiceAccount in order for NFD to create node labels. The provided templates will configure these for you.

When run as a daemonset, nodes are re-labeled at an interval specified using the --sleep-interval option. In the template the default interval is set to 60s which is also the default when no --sleep-interval is specified.

Feature discovery can alternatively be configured as a one-shot job. There is an example script in this repo that demonstrates how to deploy the job in the cluster.

./label-nodes.sh

The label-nodes.sh script tries to launch as many jobs as there are Ready nodes. Note that this approach does not guarantee running once on every node. For example, if some node is tainted NoSchedule or fails to start a job for some other reason, then some other node will run extra job instance(s) to satisfy the request and the tainted/failed node does not get labeled.

asciicast

Building from source

Download the source code.

git clone https://github.com/kubernetes-incubator/node-feature-discovery

Build the container image:

cd <project-root>
make

NOTE: Our default docker image is hosted in quay.io. To override the QUAY_REGISTRY_USER use the -e option as follows: QUAY_REGISTRY_USER=<my-username> make image -e

You can also specify a build tool different from Docker, for example:

make IMAGE_BUILD_CMD="buildah bud"

Push the container image (optional, this example with Docker)

docker push <quay-domain-name>/<registry-user>/<image-name>:<version>

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

To use your published image from the step above instead of the quay.io/kubernetes_incubator/node-feature-discovery image, edit line 40 in the file node-feature-discovery-job.json.template to the new location (<quay-domain-name>/<registry-user>/<image-name>[:<version>]).

Targeting Nodes with Specific Features

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

{
    "apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
        "labels": {
            "env": "test"
        },
        "name": "golang-test"
    },
    "spec": {
        "containers": [
            {
                "image": "golang",
                "name": "go1",
            }
        ],
        "nodeSelector": {
                "node.alpha.kubernetes-incubator.io/nfd-pstate-turbo": "true"
        }
    }
}

For more details on targeting nodes, see node selection.

References

Github issues

Design proposal

Kubernetes Incubator

This is a Kubernetes Incubator project. The project was established 2016-08-29. The incubator team for the project is:

  • Sponsor: Dawn Chen (@dchen1107)
  • Champion: David Oppenheimer (@davidopp)
  • SIG: sig-node

License

This is open source software released under the Apache 2.0 License.

Demo

A demo on the benefits of using node feature discovery can be found in demo.