1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

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.
This commit is contained in:
Markus Lehtonen 2022-07-04 17:59:53 +03:00
parent 877c4ce560
commit 59ebff46c9
5 changed files with 41 additions and 3 deletions

View file

@ -2,4 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- nodefeaturerule-crd.yaml
- nfd-api-crds.yaml

View file

@ -10,10 +10,10 @@ go generate ./cmd/... ./pkg/... ./source/...
rm -rf vendor/
controller-gen object crd output:crd:stdout paths=./pkg/apis/... > deployment/base/nfd-crds/nodefeaturerule-crd.yaml
controller-gen object crd output:crd:stdout paths=./pkg/apis/... > deployment/base/nfd-crds/nfd-api-crds.yaml
mkdir -p deployment/helm/node-feature-discovery/crds
cp deployment/base/nfd-crds/nodefeaturerule-crd.yaml deployment/helm/node-feature-discovery/crds/
cp deployment/base/nfd-crds/nfd-api-crds.yaml deployment/helm/node-feature-discovery/crds
rm -rf sigs.k8s.io

View file

@ -46,4 +46,10 @@ const (
// NodeTaintsAnnotation is the annotation that holds the taints that nfd-master set on the node
NodeTaintsAnnotation = AnnotationNs + "/taints"
// NodeFeatureObjNodeNameLabel is the label that specifies which node the
// NodeFeature object is targeting. Creators of NodeFeature objects must
// set this label and consumers of the objects are supposed to use the
// label for filtering features designated for a certain node.
NodeFeatureObjNodeNameLabel = "nfd.node.kubernetes.io/node-name"
)

View file

@ -40,6 +40,7 @@ func Resource(resource string) schema.GroupResource {
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&NodeFeature{},
&NodeFeatureRule{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)

View file

@ -21,6 +21,37 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// NodeFeatureList contains a list of NodeFeature objects.
// +kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type NodeFeatureList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []NodeFeature `json:"items"`
}
// NodeFeature resource holds the features discovered for one node in the
// cluster.
// +kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
type NodeFeature struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec NodeFeatureSpec `json:"spec"`
}
// NodeFeatureSpec describes a NodeFeature object.
type NodeFeatureSpec struct {
// Features is the full "raw" features data that has been discovered.
Features Features `json:"features"`
// Labels is the set of node labels that are requested to be created.
// +optional
Labels map[string]string `json:"labels"`
}
// Features is the collection of all discovered features.
//
// +protobuf=true