2021-08-31 11:10:12 +03:00
---
apiVersion : apiextensions.k8s.io/v1
kind : CustomResourceDefinition
2022-07-04 18:03:19 +03:00
metadata :
annotations :
2023-07-27 12:05:23 +03:00
controller-gen.kubebuilder.io/version : v0.12.1
2022-07-04 18:03:19 +03:00
name : nodefeatures.nfd.k8s-sigs.io
spec :
group : nfd.k8s-sigs.io
names :
kind : NodeFeature
listKind : NodeFeatureList
plural : nodefeatures
singular : nodefeature
scope : Namespaced
versions :
- name : v1alpha1
schema :
openAPIV3Schema :
description : NodeFeature resource holds the features discovered for one node
in the cluster.
properties :
apiVersion :
description : 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info : https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type : string
kind :
description : 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info : https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type : string
metadata :
type : object
spec :
description : NodeFeatureSpec describes a NodeFeature object.
properties :
features :
description : Features is the full "raw" features data that has been
discovered.
properties :
attributes :
additionalProperties :
description : AttributeFeatureSet is a set of features having
string value.
properties :
elements :
additionalProperties :
type : string
type : object
required :
- elements
type : object
2022-12-22 17:58:20 +02:00
description : Attributes contains all the attribute-type features
of the node.
2022-07-04 18:03:19 +03:00
type : object
flags :
additionalProperties :
description : FlagFeatureSet is a set of simple features only
containing names without values.
properties :
elements :
additionalProperties :
description : Nil is a dummy empty struct for protobuf
compatibility
type : object
type : object
required :
- elements
type : object
2022-12-22 17:58:20 +02:00
description : Flags contains all the flag-type features of the
node.
2022-07-04 18:03:19 +03:00
type : object
instances :
additionalProperties :
description : InstanceFeatureSet is a set of features each of
which is an instance having multiple attributes.
properties :
elements :
items :
description : InstanceFeature represents one instance of
a complex features, e.g. a device.
properties :
attributes :
additionalProperties :
type : string
type : object
required :
- attributes
type : object
type : array
required :
- elements
type : object
2022-12-22 17:58:20 +02:00
description : Instances contains all the instance-type features
of the node.
2022-07-04 18:03:19 +03:00
type : object
type : object
labels :
additionalProperties :
type : string
description : Labels is the set of node labels that are requested to
be created.
type : object
type : object
required :
- spec
type : object
served : true
storage : true
---
apiVersion : apiextensions.k8s.io/v1
kind : CustomResourceDefinition
2021-08-31 11:10:12 +03:00
metadata :
annotations :
2023-07-27 12:05:23 +03:00
controller-gen.kubebuilder.io/version : v0.12.1
2021-08-31 11:10:12 +03:00
name : nodefeaturerules.nfd.k8s-sigs.io
spec :
group : nfd.k8s-sigs.io
names :
kind : NodeFeatureRule
listKind : NodeFeatureRuleList
plural : nodefeaturerules
2022-09-28 12:18:49 +03:00
shortNames :
- nfr
2021-08-31 11:10:12 +03:00
singular : nodefeaturerule
scope : Cluster
versions :
- name : v1alpha1
schema :
openAPIV3Schema :
description : NodeFeatureRule resource specifies a configuration for feature-based
customization of node objects, such as node labeling.
properties :
apiVersion :
description : 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info : https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type : string
kind :
description : 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info : https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type : string
metadata :
type : object
spec :
description : NodeFeatureRuleSpec describes a NodeFeatureRule.
properties :
rules :
description : Rules is a list of node customization rules.
items :
description : Rule defines a rule for node customization such as
labeling.
properties :
2023-03-10 11:39:41 +01:00
extendedResources :
additionalProperties :
type : string
description : ExtendedResources to create if the rule matches.
type : object
2021-08-31 11:10:12 +03:00
labels :
additionalProperties :
type : string
description : Labels to create if the rule matches.
type : object
pkg/apis/nfd: support label name templating
Support templating of label names in feature rules. It is available both
in NodeFeatureRule CRs and in custom rule configuration of nfd-worker.
This patch adds a new 'labelsTemplate' field to the rule spec, making it
possible to dynamically generate multiple labels per rule based on the
matched features. The feature relies on the golang "text/template"
package. When expanded, the template must contain labels in a raw
<key>[=<value>] format (where 'value' defaults to "true"), separated by
newlines i.e.:
- name: <rule-name>
labelsTemplate: |
<label-1>[=<value-1>]
<label-2>[=<value-2>]
...
All the matched features of 'matchFeatures' directives are available for
templating engine in a nested data structure that can be described in
yaml as:
.
<domain-1>:
<key-feature-1>:
- Name: <matched-key>
- ...
<value-feature-1:
- Name: <matched-key>
Value: <matched-value>
- ...
<instance-feature-1>:
- <attribute-1-name>: <attribute-1-value>
<attribute-2-name>: <attribute-2-value>
...
- ...
<domain-2>:
...
That is, the per-feature data available for matching depends on the type
of feature that was matched:
- "key features": only 'Name' is available
- "value features": 'Name' and 'Value' can be used
- "instance features": all attributes of the matched instance are
available
NOTE: In case of matchAny is specified, the template is executed
separately against each individual matchFeatures matcher and the
eventual set of labels is a superset of all these expansions. Consider
the following:
- name: <name>
labelsTemplate: <template>
matchAny:
- matchFeatures: <matcher#1>
- matchFeatures: <matcher#2>
matchFeatures: <matcher#3>
In the example above (assuming the overall result is a match) the
template would be executed on matcher#1 and/or matcher#2 (depending on
whether both or only one of them match), and finally on matcher#3, and
all the labels from these separate expansions would be created (i.e. the
end result would be a union of all the individual expansions).
NOTE 2: The 'labels' field has priority over 'labelsTemplate', i.e.
labels specified in the 'labels' field will override any labels
originating from the 'labelsTemplate' field.
A special case of an empty match expression set matches everything (i.e.
matches/returns all existing keys/values). This makes it simpler to
write templates that run over all values. Also, makes it possible to
later implement support for templates that run over all _keys_ of a
feature.
Some example configurations:
- name: "my-pci-template-features"
labelsTemplate: |
{{ range .pci.device }}intel-{{ .class }}-{{ .device }}=present
{{ end }}
matchFeatures:
- feature: pci.device
matchExpressions:
class: {op: InRegexp, value: ["^06"]}
vendor: ["8086"]
- name: "my-system-template-features"
labelsTemplate: |
{{ range .system.osrelease }}system-{{ .Name }}={{ .Value }}
{{ end }}
matchFeatures:
- feature: system.osRelease
matchExpressions:
ID: {op: Exists}
VERSION_ID.major: {op: Exists}
Imaginative template pipelines are possible, of course, but care must be
taken in order to produce understandable and maintainable rule sets.
2021-05-04 16:30:06 +03:00
labelsTemplate :
description : LabelsTemplate specifies a template to expand for
dynamically generating multiple labels. Data (after template
expansion) must be keys with an optional value (<key>[=<value>])
separated by newlines.
type : string
2021-08-31 11:10:12 +03:00
matchAny :
description : MatchAny specifies a list of matchers one of which
must match.
items :
description : MatchAnyElem specifies one sub-matcher of MatchAny.
properties :
matchFeatures :
description : MatchFeatures specifies a set of matcher
terms all of which must match.
items :
description : FeatureMatcherTerm defines requirements
against one feature set. All requirements (specified
as MatchExpressions) are evaluated against each element
in the feature set.
properties :
feature :
type : string
matchExpressions :
additionalProperties :
description : "MatchExpression specifies an expression
to evaluate against a set of input values. It
contains an operator that is applied when matching
the input and an array of values that the operator
evaluates the input against. \n NB : CreateMatchExpression
or MustCreateMatchExpression() should be used
2022-09-08 12:45:20 +03:00
for creating new instances. \n NB : Validate()
must be called if Op or Value fields are modified
2022-07-07 21:11:40 +03:00
or if a new instance is created from scratch
2021-08-31 11:10:12 +03:00
without using the helper functions."
properties :
op :
description : Op is the operator to be applied.
enum :
- In
- NotIn
- InRegexp
- Exists
- DoesNotExist
- Gt
- Lt
- GtLt
- IsTrue
- IsFalse
type : string
value :
description : Value is the list of values that
the operand evaluates the input against.
Value should be empty if the operator is
Exists, DoesNotExist, IsTrue or IsFalse.
Value should contain exactly one element
if the operator is Gt or Lt and exactly
two elements if the operator is GtLt. In
other cases Value should contain at least
one element.
items :
type : string
type : array
required :
- op
type : object
description : MatchExpressionSet contains a set of
MatchExpressions, each of which is evaluated against
a set of input values.
type : object
required :
- feature
- matchExpressions
type : object
type : array
required :
- matchFeatures
type : object
type : array
matchFeatures :
description : MatchFeatures specifies a set of matcher terms
all of which must match.
items :
description : FeatureMatcherTerm defines requirements against
one feature set. All requirements (specified as MatchExpressions)
are evaluated against each element in the feature set.
properties :
feature :
type : string
matchExpressions :
additionalProperties :
description : "MatchExpression specifies an expression
to evaluate against a set of input values. It contains
an operator that is applied when matching the input
and an array of values that the operator evaluates
the input against. \n NB : CreateMatchExpression or
2022-07-07 21:11:40 +03:00
MustCreateMatchExpression() should be used for creating
2022-09-08 12:45:20 +03:00
new instances. \n NB : Validate() must be called if
Op or Value fields are modified or if a new instance
2021-08-31 11:10:12 +03:00
is created from scratch without using the helper functions."
properties :
op :
description : Op is the operator to be applied.
enum :
- In
- NotIn
- InRegexp
- Exists
- DoesNotExist
- Gt
- Lt
- GtLt
- IsTrue
- IsFalse
type : string
value :
description : Value is the list of values that the
operand evaluates the input against. Value should
be empty if the operator is Exists, DoesNotExist,
IsTrue or IsFalse. Value should contain exactly
one element if the operator is Gt or Lt and exactly
two elements if the operator is GtLt. In other
cases Value should contain at least one element.
items :
type : string
type : array
required :
- op
type : object
description : MatchExpressionSet contains a set of MatchExpressions,
each of which is evaluated against a set of input values.
type : object
required :
- feature
- matchExpressions
type : object
type : array
name :
description : Name of the rule.
type : string
2022-10-06 17:04:04 +03:00
taints :
description : Taints to create if the rule matches.
items :
description : The node this Taint is attached to has the "effect"
on any pod that does not tolerate the Taint.
properties :
effect :
description : Required. The effect of the taint on pods
that do not tolerate the taint. Valid effects are NoSchedule,
PreferNoSchedule and NoExecute.
type : string
key :
description : Required. The taint key to be applied to
a node.
type : string
timeAdded :
description : TimeAdded represents the time at which the
taint was added. It is only written for NoExecute taints.
format : date-time
type : string
value :
description : The taint value corresponding to the taint
key.
type : string
required :
- effect
- key
type : object
type : array
2021-06-18 18:29:08 +03:00
vars :
additionalProperties :
type : string
description : Vars is the variables to store if the rule matches.
Variables do not directly inflict any changes in the node
object. However, they can be referenced from other rules enabling
more complex rule hierarchies, without exposing intermediary
output values as labels.
type : object
2021-11-23 23:01:22 +02:00
varsTemplate :
description : VarsTemplate specifies a template to expand for
dynamically generating multiple variables. Data (after template
expansion) must be keys with an optional value (<key>[=<value>])
separated by newlines.
type : string
2021-08-31 11:10:12 +03:00
required :
- name
type : object
type : array
required :
- rules
type : object
required :
- spec
type : object
served : true
storage : true