diff --git a/deployment/base/nfd-crds/kustomization.yaml b/deployment/base/nfd-crds/kustomization.yaml index 73fd8cc08..b7f95447e 100644 --- a/deployment/base/nfd-crds/kustomization.yaml +++ b/deployment/base/nfd-crds/kustomization.yaml @@ -2,4 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- nodefeaturerule-crd.yaml +- nfd-api-crds.yaml diff --git a/hack/generate.sh b/hack/generate.sh index 9b3b5ca22..0d5c165d6 100755 --- a/hack/generate.sh +++ b/hack/generate.sh @@ -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 diff --git a/pkg/apis/nfd/v1alpha1/annotations_labels.go b/pkg/apis/nfd/v1alpha1/annotations_labels.go index 7e4cbee25..978ba853c 100644 --- a/pkg/apis/nfd/v1alpha1/annotations_labels.go +++ b/pkg/apis/nfd/v1alpha1/annotations_labels.go @@ -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" ) diff --git a/pkg/apis/nfd/v1alpha1/register.go b/pkg/apis/nfd/v1alpha1/register.go index c87a4852a..8c1d41f5b 100644 --- a/pkg/apis/nfd/v1alpha1/register.go +++ b/pkg/apis/nfd/v1alpha1/register.go @@ -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) diff --git a/pkg/apis/nfd/v1alpha1/types.go b/pkg/apis/nfd/v1alpha1/types.go index c057cddf7..3565db1cd 100644 --- a/pkg/apis/nfd/v1alpha1/types.go +++ b/pkg/apis/nfd/v1alpha1/types.go @@ -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