2016-07-23 05:13:48 +00:00
# Node feature discovery for [Kubernetes](https://kubernetes.io)
2016-09-23 21:08:03 +00:00
[![Build Status ](https://api.travis-ci.org/kubernetes-incubator/node-feature-discovery.svg?branch=master )](https://travis-ci.com/kubernetes-incubator/node-feature-discovery)
2017-08-14 13:11:23 +00:00
[![Go Report Card ](https://goreportcard.com/badge/github.com/kubernetes-incubator/node-feature-discovery )](https://goreportcard.com/report/github.com/kubernetes-incubator/node-feature-discovery)
2016-09-23 21:08:03 +00:00
2016-07-26 05:44:45 +00:00
- [Overview ](#overview )
2016-08-31 00:04:43 +00:00
- [Command line interface ](#command-line-interface )
- [Feature discovery ](#feature-discovery )
- [Feature sources ](#feature-sources )
- [Feature labels ](#feature-labels )
- [Getting started ](#getting-started )
- [System requirements ](#system-requirements )
- [Usage ](#usage )
2016-07-12 23:44:03 +00:00
- [Building from source ](#building-from-source )
2016-08-31 00:04:43 +00:00
- [Targeting nodes with specific features ](#targeting-nodes-with-specific-features )
- [References ](#references )
2016-07-26 05:44:45 +00:00
- [License ](#license )
2016-09-23 18:08:40 +00:00
- [Demo ](#demo )
2016-07-26 05:44:45 +00:00
2016-09-20 00:12:54 +00:00
_**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 ](https://github.com/kubernetes-incubator/node-feature-discovery/wiki/Users ) with as much detail as you are comfortable providing (name and email optional)._
2016-07-26 05:44:45 +00:00
## 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.
2016-12-08 22:21:53 +00:00
This project uses GitHub [milestones ](https://github.com/kubernetes-incubator/node-feature-discovery/milestones ) for release planning.
2016-08-31 00:04:43 +00:00
## Command line interface
2018-02-23 10:53:22 +00:00
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.
2016-10-26 00:05:55 +00:00
```
node-feature-discovery.
Usage:
2018-04-11 16:33:06 +00:00
node-feature-discovery [--no-publish] [--sources=< sources > ] [--label-whitelist=< pattern > ]
2018-07-06 11:11:07 +00:00
[--oneshot | --sleep-interval=< seconds > ] [--config=< path > ]
2018-09-21 08:26:57 +00:00
[--options=< config > ]
2016-10-26 00:05:55 +00:00
node-feature-discovery -h | --help
node-feature-discovery --version
Options:
-h --help Show this screen.
--version Output version and exit.
2018-07-06 11:11:07 +00:00
--config=< path > Config file to use.
[Default: /etc/kubernetes/node-feature-discovery/node-feature-discovery.conf]
2018-09-21 08:26:57 +00:00
--options=< config > 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
will override settings read from the config file.
[Default: ]
2016-10-26 00:05:55 +00:00
--sources=< sources > Comma separated list of feature sources.
2018-07-24 15:24:45 +00:00
[Default: cpuid,iommu,memory,network,pstate,rdt,selinux,storage]
2016-10-26 00:05:55 +00:00
--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: ]
2018-04-11 16:33:06 +00:00
--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]
2016-10-26 00:05:55 +00:00
```
2018-08-17 10:24:38 +00:00
**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
2018-09-27 11:54:45 +00:00
[template spec ](https://github.com/kubernetes-incubator/node-feature-discovery/blob/master/node-feature-discovery-daemonset.yaml.template )
2018-08-17 10:24:38 +00:00
for up-to-date information about the required volume mounts.
2016-08-31 00:04:43 +00:00
## Feature discovery
2016-07-26 05:44:45 +00:00
### Feature sources
2016-07-19 22:35:42 +00:00
The current set of feature sources are the following:
2018-04-10 06:05:39 +00:00
- [CPUID][cpuid] for x86/Arm64 CPU details
2018-07-24 15:24:45 +00:00
- IOMMU
2018-02-20 12:42:36 +00:00
- Memory
2017-11-28 14:47:11 +00:00
- Network
2018-07-24 15:24:45 +00:00
- Pstate ([Intel P-State driver][intel-pstate])
- RDT ([Intel Resource Director Technology][intel-rdt])
2018-03-06 19:11:44 +00:00
- Selinux
2018-07-24 15:24:45 +00:00
- Storage
2016-07-26 05:44:45 +00:00
### Feature labels
The published node labels encode a few pieces of information:
2018-10-02 13:18:04 +00:00
- A "namespace" (e.g. `node.alpha.kubernetes-incubator.io` ).
2016-07-26 05:44:45 +00:00
- 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).
2018-10-02 13:18:04 +00:00
Feature label names adhere to the following pattern:
```
< namespace > /nfd-< source name > -< feature name > [.< attribute name > ]
```
The last component (i.e. `attribute-name` ) is optional, and only used if a
feature logically has sub-hierarchy, e.g. `sriov.capable` and
`sriov.configure` from the `network` source.
2016-07-26 05:44:45 +00:00
_Note: only features that are available on a given node are labeled, so
the only label value published for features is the string `"true"` ._
```json
{
2018-09-24 07:30:55 +00:00
"node.alpha.kubernetes-incubator.io/node-feature-discovery.version": "v0.3.0",
2016-10-26 22:36:12 +00:00
"node.alpha.kubernetes-incubator.io/nfd-cpuid-< feature-name > ": "true",
2018-07-24 15:24:45 +00:00
"node.alpha.kubernetes-incubator.io/nfd-iommu-< feature-name > ": "true",
2018-02-20 12:42:36 +00:00
"node.alpha.kubernetes-incubator.io/nfd-memory-< feature-name > ": "true",
2018-02-15 12:13:18 +00:00
"node.alpha.kubernetes-incubator.io/nfd-network-< feature-name > ": "true",
2018-07-24 15:24:45 +00:00
"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"
2016-07-26 05:44:45 +00:00
}
```
2016-08-31 00:04:43 +00:00
The `--sources` flag controls which sources to use for discovery.
2016-10-28 21:40:22 +00:00
_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._
2018-04-10 06:05:39 +00:00
### X86 CPUID Features (Partial List)
2016-07-12 23:44:03 +00:00
| 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)
2018-04-10 06:05:39 +00:00
### 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
2018-07-24 15:24:45 +00:00
### 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
2017-11-28 14:47:11 +00:00
### Network Features
2018-10-02 13:18:04 +00:00
| Feature | Attribute | Description |
| ------- | ---------- | ----------------------------------------------------- |
| sriov | capable | [Single Root Input/Output Virtualization][sriov] (SR-IOV) enabled Network Interface Card(s) present
| < br > | configured | SR-IOV virtual functions have been configured
2017-11-28 14:47:11 +00:00
2018-07-24 15:24:45 +00:00
### RDT (Intel Resource Director Technology) Features
2018-02-15 12:13:18 +00:00
2018-07-24 15:24:45 +00:00
| 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
2018-02-15 12:13:18 +00:00
2018-03-06 19:11:44 +00:00
### Selinux Features
| Feature name | Description |
| :--------------: | :---------------------------------------------------------------------------------: |
| selinux | selinux is enabled on the node
2018-07-24 15:24:45 +00:00
### Storage Features
| Feature name | Description |
| :--------------: | :---------------------------------------------------------------------------------: |
| nonrotationaldisk | Non-rotational disk, like SSD, is present in the node
2016-11-14 23:05:45 +00:00
## Getting started
### System requirements
2016-07-12 23:44:03 +00:00
2018-04-10 06:05:39 +00:00
1. Linux (x86_64/Arm64)
2016-07-19 22:35:42 +00:00
1. [kubectl] [kubectl-setup] (properly set up and configured to work with your
Kubernetes cluster)
2016-07-12 23:44:03 +00:00
1. [Docker] [docker-down] (only required to build and push docker images)
### Usage
2018-04-11 16:33:06 +00:00
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:
```
2018-06-14 16:08:25 +00:00
kubectl create -f rbac.yaml
2018-09-27 11:54:45 +00:00
kubectl create -f node-feature-discovery-daemonset.yaml.template
2018-04-11 16:33:06 +00:00
```
2018-02-23 10:53:22 +00:00
When the job runs, it contacts the Kubernetes API server to add labels
to the node to advertise hardware features.
2018-06-14 16:08:25 +00:00
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.
2018-04-11 16:33:06 +00:00
When run as a daemonset, nodes are re-labeled at an interval specified using
2018-09-27 11:54:45 +00:00
the `--sleep-interval` option. In the [template ](https://github.com/kubernetes-incubator/node-feature-discovery/blob/master/node-feature-discovery-daemonset.yaml.template#L26 ) the default interval is set to 60s
2018-04-11 16:33:06 +00:00
which is also the default when no `--sleep-interval` is specified.
Feature discovery can alternatively be configured as a one-shot job. There is
2018-02-23 10:53:22 +00:00
an example script in this repo that demonstrates how to deploy the job in the cluster.
2016-07-12 00:30:49 +00:00
```
2016-07-12 23:44:03 +00:00
./label-nodes.sh
2016-07-12 00:30:49 +00:00
```
2018-02-23 10:53:22 +00:00
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.
2016-09-23 18:08:40 +00:00
[![asciicast ](https://asciinema.org/a/11wir751y89617oemwnsgli4a.png )](https://asciinema.org/a/11wir751y89617oemwnsgli4a)
2016-07-12 23:44:03 +00:00
2018-09-21 08:26:57 +00:00
### Configuration options
2018-07-06 11:11:07 +00:00
NFD supports a configuration file. The default location is
`/etc/kubernetes/node-feature-discovery/node-feature-discovery.conf` , but,
this can be changed by specifying the`--config` command line flag. The file is
read inside the Docker image, and thus, Volumes and VolumeMounts are needed to
make your configuration available for NFD. The preferred method is to use a
ConfigMap.
For example, create a config map using the example config as a template:
```
cp node-feature-discovery.conf.example node-feature-discovery.conf
vim node-feature-discovery.conf # edit the configuration
kubectl create configmap node-feature-discovery-config --from-file=node-feature-discovery.conf
```
Then, configure Volumes and VolumeMounts in the Pod spec (just the relevant
snippets shown below):
```
...
containers:
volumeMounts:
- name: node-feature-discovery-config
mountPath: "/etc/kubernetes/node-feature-discovery/"
...
volumes:
- name: node-feature-discovery-config
configMap:
name: node-feature-discovery-config
...
```
You could also use other types of volumes, of course. That is, hostPath if
different config for different nodes would be required, for example.
The (empty-by-default)
[example config ](https://github.com/kubernetes-incubator/node-feature-discovery/blob/master/node-feature-discovery.conf.example )
2018-09-21 08:26:57 +00:00
is used as a config in the NFD Docker image. Thus, this can be used as a default
2018-07-06 11:11:07 +00:00
configuration in custom-built images.
2018-09-21 08:26:57 +00:00
Configuration options can also be specified via the `--options` command line
flag, in which case no mounts need to be used. The same format as in the config
file must be used, i.e. JSON (or YAML).
Configuration options specified from the command line will override those read
from the config file.
2016-07-12 23:44:03 +00:00
## Building from source
Download the source code.
2016-07-12 00:30:49 +00:00
```
2016-08-31 00:04:43 +00:00
git clone https://github.com/kubernetes-incubator/node-feature-discovery
2016-07-12 00:30:49 +00:00
```
2018-09-12 13:40:56 +00:00
**Build the container image:**
2016-07-12 00:30:49 +00:00
```
2016-07-12 23:44:03 +00:00
cd < project-root >
2016-07-19 22:35:42 +00:00
make
2016-07-12 00:30:49 +00:00
```
2016-07-12 23:44:03 +00:00
2016-09-02 17:56:56 +00:00
**NOTE: Our default docker image is hosted in quay.io. To override the
`QUAY_REGISTRY_USER` use the `-e` option as follows:
2018-09-12 13:40:56 +00:00
`QUAY_REGISTRY_USER=<my-username> make image -e` **
2016-07-19 22:35:42 +00:00
2018-09-12 13:40:56 +00:00
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)
2016-07-12 23:44:03 +00:00
2016-07-12 00:30:49 +00:00
```
2016-09-02 17:56:56 +00:00
docker push < quay-domain-name > /< registry-user > /< image-name > :< version >
2016-07-12 00:30:49 +00:00
```
2016-07-18 19:35:38 +00:00
**Change the job spec to use your custom image (optional):**
2016-07-12 23:44:03 +00:00
To use your published image from the step above instead of the
2016-09-02 17:56:56 +00:00
`quay.io/kubernetes_incubator/node-feature-discovery` image, edit line 40 in the file
2018-09-27 11:54:45 +00:00
[node-feature-discovery-job.yaml.template ](node-feature-discovery-job.yaml.template )
2016-09-02 17:56:56 +00:00
to the new location (`< quay-domain-name > /< registry-user > /< image-name > [:< version > ]`).
2016-07-12 23:44:03 +00:00
2016-07-14 14:56:43 +00:00
## Targeting Nodes with Specific Features
2016-07-19 22:35:42 +00:00
Nodes with specific features can be targeted using the `nodeSelector` field. The
following example shows how to target nodes with Intel TurboBoost enabled.
2016-07-14 14:56:43 +00:00
2018-09-27 11:54:45 +00:00
```yaml
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'
2016-07-14 14:56:43 +00:00
```
For more details on targeting nodes, see [node selection][node-sel].
2016-08-31 00:04:43 +00:00
## References
2016-08-01 04:35:52 +00:00
Github issues
- [#28310 ](https://github.com/kubernetes/kubernetes/issues/28310 )
- [#28311 ](https://github.com/kubernetes/kubernetes/issues/28311 )
- [#28312 ](https://github.com/kubernetes/kubernetes/issues/28312 )
[Design proposal ](https://docs.google.com/document/d/1uulT2AjqXjc_pLtDu0Kw9WyvvXm-WAZZaSiUziKsr68/edit )
2016-08-31 20:19:42 +00:00
## Kubernetes Incubator
This is a [Kubernetes Incubator project ](https://github.com/kubernetes/community/blob/master/incubator.md ). 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
2016-07-14 14:56:43 +00:00
2016-07-23 05:13:48 +00:00
## License
This is open source software released under the [Apache 2.0 License ](LICENSE ).
2016-07-26 05:44:45 +00:00
2016-09-23 18:08:40 +00:00
## Demo
A demo on the benefits of using node feature discovery can be found in [demo ](demo/ ).
2016-07-26 05:44:45 +00:00
<!-- Links -->
[cpuid]: http://man7.org/linux/man-pages/man4/cpuid.4.html
[intel-rdt]: http://www.intel.com/content/www/us/en/architecture-and-technology/resource-director-technology.html
[intel-pstate]: https://www.kernel.org/doc/Documentation/cpu-freq/intel-pstate.txt
2017-11-28 14:47:11 +00:00
[sriov]: http://www.intel.com/content/www/us/en/pci-express/pci-sig-sr-iov-primer-sr-iov-technology-paper.html
2016-07-19 22:35:42 +00:00
[docker-down]: https://docs.docker.com/engine/installation
[golang-down]: https://golang.org/dl
[gcc-down]: https://gcc.gnu.org
2016-07-12 00:30:49 +00:00
[kubectl-setup]: https://coreos.com/kubernetes/docs/latest/configure-kubectl.html
2016-07-19 22:35:42 +00:00
[node-sel]: http://kubernetes.io/docs/user-guide/node-selection