Skip to content

Commit

Permalink
Add support for --instance
Browse files Browse the repository at this point in the history
Issue kubernetes-sigs/node-feature-discovery#427 proposed a way to
handle multiple NFD instances on a same cluster , this was addressed
with kubernetes-sigs/node-feature-discovery#431 patch

this patch updated the operator to support multiple instances of NFD on
the same cluster

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
  • Loading branch information
ArangoGutierrez committed Apr 16, 2021
1 parent 8ce01e4 commit bb76049
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/v1/nodefeaturediscovery_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
// +k8s:openapi-gen=true
type NodeFeatureDiscoverySpec struct {
Operand OperandSpec `json:"operand"`
Instance string `json:"instance"`
WorkerConfig ConfigMap `json:"workerConfig"`
}

Expand Down
1 change: 1 addition & 0 deletions build/assets/master/0400_master_daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
image: $(NODE_FEATURE_DISCOVERY_IMAGE)
name: nfd-master
command: ["nfd-master", "--port=12000"]
args: ["--port=12000"]
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ spec:
spec:
description: NodeFeatureDiscoverySpec defines the desired state of NodeFeatureDiscovery
properties:
instance:
description: Instance name. Used to separate annotation namespaces for multiple parallel deployments.
type: string
operand:
description: OperandSpec describes configuration options for the operand
properties:
Expand All @@ -52,8 +55,7 @@ spec:
type: string
type: object
workerConfig:
description: ConfigMap describes configuration options for the NFD
worker
description: WorkerConfig describes configuration options for the NFD worker
properties:
configData:
description: BinaryData holds the NFD configuration file
Expand Down
8 changes: 8 additions & 0 deletions controllers/nodefeaturediscovery_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"fmt"

secv1 "github.com/openshift/api/security/v1"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -305,6 +306,13 @@ func DaemonSet(n NFD) (ResourceStatus, error) {
obj.Spec.Template.Spec.Containers[0].ImagePullPolicy = n.ins.Spec.Operand.ImagePolicy(n.ins.Spec.Operand.ImagePullPolicy)
}

// check if running as instance
// https://kubernetes-sigs.github.io/node-feature-discovery/v0.8/advanced/master-commandline-reference.html#-instance
if n.ins.Spec.Instance != "" && obj.ObjectMeta.Name == "nfd-master" {
instanceFlag := fmt.Sprintf("--instance=%s", n.ins.Spec.Instance)
obj.Spec.Template.Spec.Containers[0].Args = []string{"--port=12000", instanceFlag}
}

obj.SetNamespace(n.ins.GetNamespace())

found := &appsv1.DaemonSet{}
Expand Down

0 comments on commit bb76049

Please sign in to comment.