Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for extra-label-ns, label-whitelist, resource-labels #77

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api/v1/nodefeaturediscovery_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ type NodeFeatureDiscoverySpec struct {
// +optional
Instance string `json:"instance"`

// ExtraLabelNs defines the list of of allowed extra label namespaces
// By default, only allow labels in the default `feature.node.kubernetes.io` label namespace
// +nullable
// +kubebuilder:validation:Optional
marquiz marked this conversation as resolved.
Show resolved Hide resolved
ExtraLabelNs []string `json:"extraLabelNs,omitempty"`

// ResourceLabels defines the list of features
// to be advertised as extended resources instead of labels.
// +nullable
// +kubebuilder:validation:Optional
marquiz marked this conversation as resolved.
Show resolved Hide resolved
ResourceLabels []string `json:"resourceLabels,omitempty"`

// LabelWhiteList defines a regular expression
// for filtering feature labels based on their name.
// Each label must match against the given reqular expression in order to be published.
// +nullable
// +kubebuilder:validation:Optional
marquiz marked this conversation as resolved.
Show resolved Hide resolved
LabelWhiteList string `json:"labelWhiteList,omitempty"`

// WorkerConfig describes configuration options for the NFD
// worker.
// +optional
Expand Down
12 changes: 11 additions & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions config/crd/bases/nfd.kubernetes.io_nodefeaturediscoveries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,24 @@ spec:
spec:
description: NodeFeatureDiscoverySpec defines the desired state of NodeFeatureDiscovery
properties:
extraLabelNs:
description: ExtraLabelNs defines the list of of allowed extra label
namespaces By default, only allow labels in the default `feature.node.kubernetes.io`
label namespace
items:
type: string
nullable: true
type: array
instance:
description: Instance name. Used to separate annotation namespaces
for multiple parallel deployments.
type: string
labelWhiteList:
description: LabelWhiteList defines a regular expression for filtering
feature labels based on their name. Each label must match against
the given reqular expression in order to be published.
nullable: true
type: string
operand:
description: OperandSpec describes configuration options for the operand
properties:
Expand All @@ -63,6 +77,13 @@ spec:
listens for incoming requests.
type: integer
type: object
resourceLabels:
description: ResourceLabels defines the list of features to be advertised
as extended resources instead of labels.
items:
type: string
nullable: true
type: array
workerConfig:
description: WorkerConfig describes configuration options for the
NFD worker.
Expand Down
5 changes: 5 additions & 0 deletions config/samples/nfd.kubernetes.io_v1_nodefeaturediscovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ metadata:
namespace: node-feature-discovery-operator
spec:
instance: "" # instance is empty by default
#labelWhiteList: ""
#extraLabelNs:
# - "example.com"
#resourceLabels:
# - "example.com/resource"
operand:
namespace: node-feature-discovery-operator
image: gcr.io/k8s-staging-nfd/node-feature-discovery:master
Expand Down
13 changes: 13 additions & 0 deletions controllers/nodefeaturediscovery_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"strings"

secv1 "github.com/openshift/api/security/v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -324,6 +325,18 @@ func DaemonSet(n NFD) (ResourceStatus, error) {
args = append(args, fmt.Sprintf("--instance=%s", n.ins.Spec.Instance))
}

if len(n.ins.Spec.ExtraLabelNs) != 0 {
args = append(args, fmt.Sprintf("--extra-label-ns=%s", strings.Join(n.ins.Spec.ExtraLabelNs, ",")))
}

if len(n.ins.Spec.ResourceLabels) != 0 {
args = append(args, fmt.Sprintf("--resource-labels=%s", strings.Join(n.ins.Spec.ResourceLabels, ",")))
}
marquiz marked this conversation as resolved.
Show resolved Hide resolved

if strings.TrimSpace(n.ins.Spec.LabelWhiteList) != "" {
args = append(args, fmt.Sprintf("--label-whitelist=%s", n.ins.Spec.LabelWhiteList))
}

obj.Spec.Template.Spec.Containers[0].Args = args
}

Expand Down