1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-15 17:50:49 +00:00
Commit graph

1452 commits

Author SHA1 Message Date
Markus Lehtonen
27c47bd088 docs: better document differences between deployment methods 2022-12-20 16:29:48 +02:00
Kubernetes Prow Robot
c551a9a89b
Merge pull request #1005 from marquiz/devel/e2e-lint
Simplify usage of ObjectMeta fields
2022-12-19 08:01:45 -08:00
Markus Lehtonen
f5ae3fe2c7 Simplify usage of ObjectMeta fields
No need to explicitly spell out ObjectMeta as it's embedded in the
object types.
2022-12-19 17:40:10 +02:00
Kubernetes Prow Robot
e2296998d6
Merge pull request #1001 from marquiz/devel/e2e-nodefeature
test/e2e: add basic e2e-tests for NodeFeature API
2022-12-19 07:19:44 -08:00
Markus Lehtonen
b67d6d7282 test/e2e: add basic e2e-tests for NodeFeature API
Add an initial test set for the NodeFeature API. This is done simply by
running a second pass of the tests but with -enable-nodefeature-api
(i.e. NodeFeature API enabled and gRPC disabled). This should give basic
confidence that the API actually works and form a basis for further
imporovements on testing the new CRD API.
2022-12-19 16:58:21 +02:00
Markus Lehtonen
958db56680 test/e2e: isolate tests into a separate function
Preparation for running the same tests with NodeFeature API enabled
(instead of gRPC).
2022-12-19 14:08:05 +02:00
Kubernetes Prow Robot
e684197634
Merge pull request #932 from fmuyassarov/e2e-taints
Add E2E test for NFD tainting feature
2022-12-19 03:59:45 -08:00
Feruzjon Muyassarov
3e29f5c5df Add nfd E2E tests for tainting feature
Extend current E2E tests to check tainting feature of nfd implemented
in https://github.com/kubernetes-sigs/node-feature-discovery/pull/910

Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-12-19 13:39:03 +02:00
Kubernetes Prow Robot
4635b99832
Merge pull request #1003 from marquiz/devel/e2e-host-usr-src
test/e2e: drop host-usr-src mount
2022-12-19 02:35:45 -08:00
Kubernetes Prow Robot
28a5daa338
Merge pull request #999 from marquiz/fixes/nodefeature-missing
nfd-master: update node if no NodeFeature objects are present
2022-12-19 00:39:44 -08:00
Markus Lehtonen
4c955ad72c nfd-master: update node if no NodeFeature objects are present
Correctly handle the case where no NodeFeature objects exist for certain
node (and NodeFeature API has been enabled with
-enable-nodefeature-api). In this case all the labels should be removed.
2022-12-19 10:22:04 +02:00
Kubernetes Prow Robot
c250a8bea8
Merge pull request #1004 from marquiz/fixes/e2e
test/e2e: don't expect control-plane nodes to be labeled
2022-12-17 00:11:41 -08:00
Markus Lehtonen
51f4c5447b test/e2e: don't expect control-plane nodes to be labeled
Without this e2e tests may fail in clusters with control-plane-only
nodes.
2022-12-16 22:56:19 +02:00
Kubernetes Prow Robot
941a55ae0b
Merge pull request #998 from marquiz/fixes/nodefeature-crd-startup
nfd-master: update all nodes at startup when NodeFeature API enabled
2022-12-16 05:06:20 -08:00
Kubernetes Prow Robot
87c1a3d47d
Merge pull request #1002 from marquiz/devel/e2e-podsecurity
test/e2e: drop pod security enforcement label from the test namespace
2022-12-15 23:01:37 -08:00
Kubernetes Prow Robot
8d2adfd1f5
Merge pull request #996 from fmuyassarov/parametirize-image
E2E: parameterize container image and tag
2022-12-15 08:35:37 -08:00
Markus Lehtonen
7b2add434c test/e2e: drop pod security enforcement label from the test namespace
Drop the pod-security.kubernetes.io/enforce label from the test
namespace, i.e. remove pod security admission enforcement. NFD-worker
uses restricted host mounts (/sys) etc so pod creation fails even in
privileged mode if pod security admission enforcement is enabled.
2022-12-15 17:43:44 +02:00
Markus Lehtonen
fd0b812433 test/e2e: drop host-usr-src mount
Allows running e2e-tests in some more restricted environments.
2022-12-15 16:49:27 +02:00
Kubernetes Prow Robot
a193098513
Merge pull request #903 from marquiz/devel/nodefeature-crd
docs: document NodeFeature API
2022-12-14 13:05:36 -08:00
Kubernetes Prow Robot
323fd5c6ec
Merge pull request #995 from fmuyassarov/seccomp-profile-nfd-worker
E2E: default seccompProfile to runtimeDefault for nfd worker
2022-12-14 12:45:34 -08:00
Markus Lehtonen
3209c14bea docs: document NodeFeature API
Document the usage of the NodeFeature CRD API. Also re-organize the
documentation a bit, moving the description of NodeFeatureRule
controller from customization guide to nfd-master usage page.
2022-12-14 22:33:12 +02:00
Kubernetes Prow Robot
33e44d53b9
Merge pull request #1000 from marquiz/fixes/e2e
test/e2e: fix mistake in ginkgo focus
2022-12-14 12:19:34 -08:00
Markus Lehtonen
f04e1a9404 test/e2e: fix mistake in ginkgo focus
Leftover from development that got accidentally merged in
43910e6925
2022-12-14 21:59:15 +02:00
Markus Lehtonen
b9c09e6674 nfd-master: update all nodes at startup when NodeFeature API enabled
We want to always update all nodes at startup. Without this patch we
don't get any update event from the controller if no NodeFeature or
NodeFeatureRule objects exist in the cluster. Thus all nodes would stay
untouched whereas we really want to remove all labels from all nodes in
this case.
2022-12-14 21:49:50 +02:00
Kubernetes Prow Robot
a36f6a6409
Merge pull request #997 from marquiz/devel/e2e-crd-creation
test/e2e: create CRDs once in the beginning of the tests
2022-12-14 11:49:35 -08:00
Markus Lehtonen
43910e6925 test/e2e: create CRDs once in the beginning of the tests
Only generate CRDs once in the beginning of the test run. Use the "Ordered"
option for the test container so that we can utilize ginkgo.BeforeAll to
only do stuff once before the first test. Changing from unordered to
ordered shouldn't make a big difference here.

Add a cleanup function to remove stale NodeFeatureRule objects that are
cluster-scoped and not deleted with the test namespace.
2022-12-14 18:42:00 +02:00
Kubernetes Prow Robot
d1b314842c
Merge pull request #989 from marquiz/devel/nodefeature-multi-object
nfd-master: handle multiple NodeFeature objects
2022-12-14 07:51:34 -08:00
Kubernetes Prow Robot
586bf7eefe
Merge pull request #994 from fmuyassarov/config-defaulting
E2E: default kubeconfig location to ${HOME}/.kube/config
2022-12-14 07:29:35 -08:00
Feruzjon Muyassarov
5d08f1cd7c E2E:parameterize container image and tag
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-12-14 17:16:03 +02:00
Feruzjon Muyassarov
39813e7a73 E2E: default kubeconfig location to ${HOME}/.kube/config
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-12-14 17:09:08 +02:00
Feruzjon Muyassarov
ae8ba01c2c E2E: default seccompProfile to runtimeDefault for nfd worker
Use RuntimeDefault seccomp profile in nfd worker and topology
updater pod spec similar to nfd master.

Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-12-14 17:04:38 +02:00
Kubernetes Prow Robot
019383848e
Merge pull request #990 from marquiz/devel/nodefeature-ratelimit
nfd-master: implement ratelimiter for nfd api updates
2022-12-14 06:07:34 -08:00
Markus Lehtonen
740e3af681 nfd-master: implement ratelimiter for nfd api updates
Implement a naive ratelimiter for node update events originating from
the nfd API. We might get a ton of events in short interval. The
simplest example is startup when we get a separate Add event for every
NodeFeature and NodeFeatureRule object. Without rate limiting we
run "update all nodes" separately for each NodeFeatureRule object, plus,
we would run "update node X" separately for each NodeFeature object
targeting node X. This is a huge amount of wasted work because in
principle just running "update all nodes" once should be enough.
2022-12-14 15:45:43 +02:00
Markus Lehtonen
79ed747be8 nfd-master: handle multiple NodeFeature objects
Implement handling of multiple NodeFeature objects by merging all
objects (targeting a certain node) into one before processing the data.
This patch implements MergeInto() methods for all required data types.

With support for multiple NodeFeature objects per node, The "nfd api
workflow" can be easily demonstrated and tested from the command line.
Creating the folloiwing object (assuming node-n exists in the cluster):

    apiVersion: nfd.k8s-sigs.io/v1alpha1
    kind: NodeFeature
    metadata:
      labels:
        nfd.node.kubernetes.io/node-name: node-n
      name: my-features-for-node-n
    spec:
      # Features for NodeFeatureRule matching
      features:
        flags:
          vendor.domain-a:
            elements:
              feature-x: {}
        attributes:
          vendor.domain-b:
            elements:
              feature-y: "foo"
              feature-z: "123"
        instances:
          vendor.domain-c:
            elements:
            - attributes:
                name: "elem-1"
                vendor: "acme"
            - attributes:
                name: "elem-2"
                vendor: "acme"
      # Labels to be created
      labels:
        vendor-feature.enabled: "true"
        vendor-setting.value: "100"

will create two feature labes:

    feature.node.kubernetes.io/vendor-feature.enabled: "true"
    feature.node.kubernetes.io/vendor-setting.value: "100"

In addition it will advertise hidden/raw features that can be used for
custom rules in NodeFeatureRule objects. Now, creating a NodeFeatureRule
object:

    apiVersion: nfd.k8s-sigs.io/v1alpha1
    kind: NodeFeatureRule
    metadata:
      name: my-rule
    spec:
      rules:
        - name: "my feature rule"
          labels:
            "my-feature": "true"
          matchFeatures:
            - feature: vendor.domain-a
              matchExpressions:
                feature-x: {op: Exists}
            - feature: vendor.domain-c
              matchExpressions:
                vendor: {op: In, value: ["acme"]}

will match the features in the NodeFeature object above and cause one
more label to be created:

    feature.node.kubernetes.io/my-feature: "true"
2022-12-14 15:44:52 +02:00
Kubernetes Prow Robot
ee0807da66
Merge pull request #993 from marquiz/fixes/e2e
test/e2e: fix creation of NFD CRDs
2022-12-14 05:37:35 -08:00
Markus Lehtonen
13f3959ebe test/e2e: fix creation of NFD CRDs
After introducing NodeFeatureRule we packed two CRD definitions in one
yaml file. Our e2e-tests were not prepared to that and the file itself
was also renamed so it couldn't even be read by the test suite.

With this change the e2e-tests start to create NodeFeatre CRD in the
test cluster, preparing for the addition of e2e-tests for NodeFeature
API.
2022-12-14 14:44:17 +02:00
Kubernetes Prow Robot
e10957009b
Merge pull request #992 from marquiz/fixes/enable-nodefeature-flag
nfd-master: fix creation of the -enable-nodefeature-api flag
2022-12-14 03:37:34 -08:00
Kubernetes Prow Robot
cb7e8ac583
Merge pull request #991 from marquiz/devel/nodefeature-flag-rename
nfd-master: rename -featurerules-controller flag to -crd-controller
2022-12-14 03:15:33 -08:00
Markus Lehtonen
81b0945ced nfd-master: fix creation of the -enable-nodefeature-api flag
Extra dash caused a panic when trying to run the binary.
2022-12-14 12:51:14 +02:00
Markus Lehtonen
9f0806593d nfd-master: rename -featurerules-controller flag to -crd-controller
Deprecate the '-featurerules-controller' command line flag as the name
does not describe the functionality anymore: in practice it controls the
CRD controller handling both NodeFeature and NodeFeatureRule objects.
The patch introduces a duplicate, more generally named, flag
'-crd-controller'. A warning is printed in the log if
'-featurerules-controller' flag is encountered.
2022-12-14 10:23:45 +02:00
Kubernetes Prow Robot
8a153c12cf
Merge pull request #986 from marquiz/devel/nodefeature-crd-base
Introduce NodeFeature CRD
2022-12-14 00:17:34 -08:00
Markus Lehtonen
5a717c418b docs: small reordering of master cmdline reference
Move documentation of -enable-taints near '-enable-nodefeature-api' and
'-no-publish' as they are related in that they control the enablement of
APIs.
2022-12-14 07:31:28 +02:00
Markus Lehtonen
6ddd87e465 nfd-master: support NodeFeature objects
Add initial support for handling NodeFeature objects. With this patch
nfd-master watches NodeFeature objects in all namespaces and reacts to
changes in any of these. The node which a certain NodeFeature object
affects is determined by the "nfd.node.kubernetes.io/node-name"
annotation of the object. When a NodeFeature object targeting certain
node is changed, nfd-master needs to process all other objects targeting
the same node, too, because there may be dependencies between them.

Add a new command line flag for selecting between gRPC and NodeFeature
CRD API as the source of feature requests. Enabling NodeFeature API
disables the gRPC interface.

 -enable-nodefeature-api   enable NodeFeature CRD API for incoming
                           feature requests, will disable the gRPC
                           interface (defaults to false)

It is not possible to serve gRPC and watch NodeFeature objects at the
same time. This is deliberate to avoid labeling races e.g. by nfd-worker
sending gRPC requests but NodeFeature objects in the cluster
"overriding" those changes (labels from the gRPC requests will get
overridden when NodeFeature objects are processed).
2022-12-14 07:31:28 +02:00
Markus Lehtonen
237494463b nfd-worker: support creating NodeFeatures object
Support the new NodeFeatures object of the NFD CRD api. Add two new
command line options to nfd-worker:

 -kubeconfig               specifies the kubeconfig to use for
                           connecting k8s api (defaults to empty which
                           implies in-cluster config)
 -enable-nodefeature-api   enable the NodeFeature CRD API for
                           communicating node features to nfd-master,
                           will also automatically disable gRPC
                           (defgault to false)

No config file option for selecting the API is available as there should
be no need for dynamically selecting between gRPC and CRD. The
nfd-master configuration must be changed in tandem and it is safer (and
avoid awkward configuration races) to configure the whole NFD deployment
at once.

Default behavior of nfd-worker is not changed i.e. NodeFeatures object
creation is not enabled by default (but must be enabled with the command
line flag).

The patch also updates the kustomize and Helm deployment, adding RBAC
rules for nfd-worker and updating the example worker configuration.
2022-12-14 07:31:28 +02:00
Markus Lehtonen
d1c91e129a apis/nfd: update auto-generated code 2022-12-14 07:31:28 +02:00
Markus Lehtonen
59ebff46c9 apis/nfd: add CRD for communicating node features
Add a new NodeFeature CRD to the nfd Kubernetes API to communicate node
features over K8s api objects instead of gRPC. The new resource is
namespaced which will help the management of multiple NodeFeature
objects per node. This aims at enabling 3rd party detectors for custom
features.

In addition to communicating raw features the NodeFeature object also
has a field for directly requesting labels that should be applied on the
node object.

Rename the crd deployment file to nfd-api-crds.yaml so that it matches
the new content of the file. Also, rename the Helm subdir for CRDs to
match the expected chart directory structure.
2022-12-14 07:31:28 +02:00
Kubernetes Prow Robot
877c4ce560
Merge pull request #988 from marquiz/devel/nfd-master-errcheck
nfd-master: add error checking for CRD controller creation
2022-12-13 14:57:33 -08:00
Markus Lehtonen
079655b42c nfd-master: add error checking for CRD controller creation 2022-12-14 00:27:27 +02:00
Kubernetes Prow Robot
6975680195
Merge pull request #987 from fmuyassarov/bump-k8s
Bump go.mod k8s.io to 1.26
2022-12-13 02:31:34 -08:00
Feruzjon Muyassarov
b296bdf0b3 update test functions according to upstream deprecated/removed methods
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
2022-12-13 12:12:50 +02:00