</code></pre></div></div><h3id="docker-build">Docker build</h3><h4id="build-the-container-image">Build the container image</h4><p>See <ahref="#customizing-the-build">customizing the build</a> below for altering the container image registry, for example.</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make
</code></pre></div></div><h4id="push-the-container-image">Push the container image</h4><p>Optional, this example with Docker.</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>docker push <IMAGE_TAG>
</code></pre></div></div><h4id="change-the-job-spec-to-use-your-custom-image-optional">Change the job spec to use your custom image (optional)</h4><p>To use your published image from the step above instead of the <codeclass="language-plaintext highlighter-rouge notranslate">k8s.gcr.io/nfd/node-feature-discovery</code> image, edit <codeclass="language-plaintext highlighter-rouge notranslate">image</code> attribute in the spec template(s) to the new location (<codeclass="language-plaintext highlighter-rouge notranslate"><registry-name>/<image-name>[:<version>]</code>).</p><h3id="deployment">Deployment</h3><p>The <codeclass="language-plaintext highlighter-rouge notranslate">yamls</code> makefile generates deployment specs matching your locally built image. See <ahref="#customizing-the-build">build customization</a> below for configurability, e.g. changing the deployment namespace.</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">K8S_NAMESPACE</span><spanclass="o">=</span>my-ns make yamls
</code></pre></div></div><p>Alternatively, deploying worker and master in the same pod:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">K8S_NAMESPACE</span><spanclass="o">=</span>my-ns make yamls
</code></pre></div></div><p>Or worker as a one-shot job:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">K8S_NAMESPACE</span><spanclass="o">=</span>my-ns make yamls
<spanclass="nv">NUM_NODES</span><spanclass="o">=</span><spanclass="si">$(</span>kubectl get no <spanclass="nt">-o</span><spanclass="nv">jsonpath</span><spanclass="o">=</span><spanclass="s1">'{.items[*].metadata.name}'</span> | <spanclass="nb">wc</span><spanclass="nt">-w</span><spanclass="si">)</span>
</code></pre></div></div><h3id="building-locally">Building locally</h3><p>You can also build the binaries locally</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make build
</code></pre></div></div><p>This will compile binaries under <codeclass="language-plaintext highlighter-rouge notranslate">bin/</code></p><h3id="customizing-the-build">Customizing the build</h3><p>There are several Makefile variables that control the build process and the name of the resulting container image. The following are targeted targeted for build customization and they can be specified via environment variables or makefile overrides.</p><table><thead><tr><th>Variable</th><th>Description</th><th>Default value</th></tr></thead><tbody><tr><td>HOSTMOUNT_PREFIX</td><td>Prefix of system directories for feature discovery (local builds)</td><td>/ (<em>local builds</em>) /host- (<em>container builds</em>)</td></tr><tr><td>IMAGE_BUILD_CMD</td><td>Command to build the image</td><td>docker build</td></tr><tr><td>IMAGE_BUILD_EXTRA_OPTS</td><td>Extra options to pass to build command</td><td><em>empty</em></td></tr><tr><td>IMAGE_PUSH_CMD</td><td>Command to push the image to remote registry</td><td>docker push</td></tr><tr><td>IMAGE_REGISTRY</td><td>Container image registry to use</td><td>k8s.gcr.io/nfd</td></tr><tr><td>IMAGE_TAG_NAME</td><td>Container image tag name</td><td><nfd version></td></tr><tr><td>IMAGE_EXTRA_TAG_NAMES</td><td>Additional container image tag(s) to create when building image</td><td><em>empty</em></td></tr><tr><td>K8S_NAMESPACE</td><td>nfd-master and nfd-worker namespace</td><td>node-feature-discovery</td></tr><tr><td>KUBECONFIG</td><td>Kubeconfig for running e2e-tests</td><td><em>empty</em></td></tr><tr><td>E2E_TEST_CONFIG</td><td>Parameterization file of e2e-tests (see <ahref="https://github.com/kubernetes-sigs/node-feature-discovery/blob/v0.7.0/test/e2e/e2e-test-config.exapmle.yaml">example</a>)</td><td><em>empty</em></td></tr></tbody></table><p>For example, to use a custom registry:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make <spanclass="nv">IMAGE_REGISTRY</span><spanclass="o">=</span><my custom registry uri>
</code></pre></div></div><p>Or to specify a build tool different from Docker, It can be done in 2 ways:</p><ol><li>via environment <divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">IMAGE_BUILD_CMD</span><spanclass="o">=</span><spanclass="s2">"buildah bud"</span> make
</code></pre></div></div></li><li>by overriding the variable value <divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make <spanclass="nv">IMAGE_BUILD_CMD</span><spanclass="o">=</span><spanclass="s2">"buildah bud"</span>
</code></pre></div></div></li></ol><h3id="testing">Testing</h3><p>Unit tests are automatically run as part of the container image build. You can also run them manually in the source code tree by simply running:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make <spanclass="nb">test</span>
</code></pre></div></div><p>End-to-end tests are built on top of the e2e test framework of Kubernetes, and, they required a cluster to run them on. For running the tests on your test cluster you need to specify the kubeconfig to be used:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make e2e-test <spanclass="nv">KUBECONFIG</span><spanclass="o">=</span><spanclass="nv">$HOME</span>/.kube/config
</code></pre></div></div><h2id="running-locally">Running locally</h2><p>You can run NFD locally, either directly on your host OS or in containers for testing and development purposes. This may be useful e.g. for checking features-detection.</p><h3id="nfd-master">NFD-Master</h3><p>When running as a standalone container labeling is expected to fail because Kubernetes API is not available. Thus, it is recommended to use <codeclass="language-plaintext highlighter-rouge notranslate">--no-publish</code> command line flag. E.g.</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">$ </span><spanclass="nb">export </span><spanclass="nv">NFD_CONTAINER_IMAGE</span><spanclass="o">=</span>k8s.gcr.io/nfd/node-feature-discovery:v0.7.0
2019/02/01 14:48:21 gRPC server serving on port: 8080
</code></pre></div></div><p>Command line flags of nfd-master:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">$ </span>docker run <spanclass="nt">--rm</span><spanclass="k">${</span><spanclass="nv">NFD_CONTAINER_IMAGE</span><spanclass="k">}</span> nfd-master <spanclass="nt">--help</span>
</code></pre></div></div><h3id="nfd-worker">NFD-Worker</h3><p>In order to run nfd-worker as a "stand-alone" container against your standalone nfd-master you need to run them in the same network namespace:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">$ </span>docker run <spanclass="nt">--rm</span><spanclass="nt">--network</span><spanclass="o">=</span>container:nfd-test <spanclass="k">${</span><spanclass="nv">NFD_CONTAINER_IMAGE</span><spanclass="k">}</span> nfd-worker
</code></pre></div></div><p>If you just want to try out feature discovery without connecting to nfd-master, pass the <codeclass="language-plaintext highlighter-rouge notranslate">--no-publish</code> flag to nfd-worker.</p><p>Command line flags of nfd-worker:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code><spanclass="nv">$ </span>docker run <spanclass="nt">--rm</span><spanclass="k">${</span><spanclass="nv">NFD_CONTAINER_IMAGE</span><spanclass="k">}</span> nfd-worker <spanclass="nt">--help</span>
<spanclass="nt">--server</span><spanclass="o">=</span><server> NFD server address to connecto to.
<spanclass="o">[</span>Default: localhost:8080]
<spanclass="nt">--server-name-override</span><spanclass="o">=</span><name> Name <spanclass="o">(</span>CN<spanclass="o">)</span> expect from server certificate, useful
</code></pre></div></div><p><strong>NOTE</strong> 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 <codeclass="language-plaintext highlighter-rouge notranslate">--volume</code> options in order for them to work correctly when run stand-alone directly with <codeclass="language-plaintext highlighter-rouge notranslate">docker run</code>. See the <ahref="https://github.com/kubernetes-sigs/node-feature-discovery/blob/v0.7.0/nfd-worker-daemonset.yaml.template">template spec</a> for up-to-date information about the required volume mounts.</p><h2id="documentation">Documentation</h2><p>All documentation resides under the <ahref="https://github.com/kubernetes-sigs/node-feature-discovery/tree/v0.7.0/docs">docs</a> directory in the source tree. It is designed to be served as a html site by <ahref="https://pages.github.com/">GitHub Pages</a>.</p><p>Building the documentation is containerized in order to fix the build environment. The recommended way for developing documentation is to run:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make site-serve
</code></pre></div></div><p>This will build the documentation in a container and serve it under <ahref="http://localhost:4000/">localhost:4000/</a> making it easy to verify the results. Any changes made to the <codeclass="language-plaintext highlighter-rouge notranslate">docs/</code> will automatically re-trigger a rebuild and are reflected in the served content and can be inspected with a simple browser refresh.</p><p>In order to just build the html documentation run:</p><divclass="language-bash highlighter-rouge notranslate"><divclass="highlight"><preclass="highlight"><code>make site-build
</code></pre></div></div><p>This will generate html documentation under <codeclass="language-plaintext highlighter-rouge notranslate">docs/_site/</code>.</p><!-- Links --></div></div><divclass="navigation-bottom d-flex flex-justify-between py-3"role="navigation"aria-label="footer navigation"><divclass="prev"></div><divclass="next"><ahref="/node-feature-discovery/v0.7/advanced/master-commandline-reference.html"class="btn"title="Master cmdline reference"accesskey="n"rel="next"> Next <iclass="fa fa-arrow-circle-right"></i></a></div></div><hr><divclass="copyright text-center text-gray"role="contentinfo"><iclass="fa fa-copyright"></i><spanclass="time">2016-2023,</span><aclass="text-gray"href="https://github.com/kubernetes-sigs"rel="noreferrer"target="_blank">Kubernetes SIGs</a> Revision <aclass="text-gray"href="https://github.com/kubernetes-sigs/node-feature-discovery/commit/"title=""rel="noreferrer"target="_blank"></a><br><divclass="generator"> Built with <ahref="https://jekyllrb.com"rel="noreferrer"target="_blank">Jekyll</a> using a <ahref="https://github.com/rundocs/jekyll-rtd-theme"rel="noreferrer"target="_blank"title="remote theme: jekyll-rtd-theme v2.0.9">theme</a> provided by <ahref="https://rundocs.io"rel="noreferrer"target="_blank">RunDocs</a>. </div></div></div></div><divclass="addons-wrap d-flex flex-column overflow-y-auto"><divclass="status d-flex flex-justify-between p-2"><divclass="title p-1"><iclass="fa fa-book"></i> Node Feature Discovery </div><divclass="branch p-1"><spanclass="name"> v0.7 </span><iclass="fa fa-caret-down"></i></div></div><divclass="addons d-flex flex-column height-full p-2 d-none"><dlid="versions"><dt>Versions</dt><scriptsrc="/node-feature-discovery/versions.js"></script><script>vardt=document.getElementById('versions');varitems=getVersionListItems();for(vari=0;i<items.length;i++){vardd=document.createElement('dd');vara=dd.appendChild(document.createElement('a'));a.appendChild(document.createTextNode(items[i].name));a.href=items[i].url;dt.appendChild(dd);}</script></dl><dl><dt>GitHub</dt><dd><ahref="https://github.com/kubernetes-sigs/node-feature-discovery"title="Stars: 548"><iclass="fa fa-github"></i> Homepage </a></dd><dd><ahref="https://github.com/kubernetes-sigs/node-feature-discovery/issues"title="Open issues: 31"><iclass="fa fa-question-circle-o"></i> Issues </a></dd><dd><ahref="https://github.com/kubernetes-sigs/node-feature-discovery/zipball/gh-pages"title="Size: 88715 Kb"><iclass="fa fa-download"></i> Download </a></dd></dl><hr><divclass="license f6 pb-2"> The <ahref="/node-feature-discovery/v0.7/">software</a> is under the terms of <ahref="https://github.com/kubernetes-sigs/node-feature-discovery">Apache License 2.0</a>. </div></div></div><script>window.ui={title:"Node Feature Discovery",baseurl:"/node-feature-discovery/v0.7",i18n:{search_results:"Search Results",search_results_found:"Search finished, found # page(s) matching the search query.",search_results_not_found:"Your search did not match any documents, please make sure that all characters are spelled correctly!"}};</script><scriptsrc="https://cdn.jsdelivr.net/gh/rundocs/jekyll-rtd-theme@2.0.9/assets/js/jquery.min.js"></script><scriptsrc="https://cdn.jsdelivr.net/gh/rundocs/jekyll-rtd-theme@2.0.9/assets/js/theme.min.js"></script></body></html>