diff --git a/cmd/nfd-master/main.go b/cmd/nfd-master/main.go index 07c41c50f0..48d509389b 100644 --- a/cmd/nfd-master/main.go +++ b/cmd/nfd-master/main.go @@ -96,6 +96,8 @@ func initFlags(flagset *flag.FlagSet) *master.Args { "NB: the label namespace is omitted i.e. the filter is only applied to the name part after '/'.") flagset.BoolVar(&args.NoPublish, "no-publish", false, "Do not publish feature labels") + flagset.BoolVar(&args.NoTaint, "no-taint", true, + "Do not set node taint defined on the NodeFeatureRule CR") flagset.BoolVar(&args.FeatureRulesController, "featurerules-controller", true, "Enable controller for NodeFeatureRule objects. Generates node labels based on the rules in these CRs.") flagset.IntVar(&args.Port, "port", 8080, diff --git a/docs/advanced/customization-guide.md b/docs/advanced/customization-guide.md index 959151cf39..46e15f18da 100644 --- a/docs/advanced/customization-guide.md +++ b/docs/advanced/customization-guide.md @@ -30,8 +30,11 @@ labeling: ## NodeFeatureRule custom resource `NodeFeatureRule` objects provide an easy way to create vendor or application -specific labels and taints (disabled by default). It uses a flexible rule-based -mechanism for creating labels/taints based on node feature. +specific labels and taints. It uses a flexible rule-based mechanism for creating +labels/taints based on node features. Tainting feature is disabled by default and +to enable it set `--no-taint` flag to `false`. If the feature gate `--no-taint` +is `true` (i.e. disabled), taints defined in the NodeFeatureRule CRD have no effect +and will be ignored by the NFD controller. ### A NodeFeatureRule example @@ -47,7 +50,7 @@ spec: - name: "my sample rule" labels: "my-sample-feature": "true" -# Using tainting feature requires the feature gate (--allowTainting) to be enabled +# Using tainting feature requires the feature gate (--no-taint) to be enabled (set to false) taints: - effect: PreferNoSchedule key: bar @@ -1044,4 +1047,3 @@ __In the example above:__ matches the `node-datacenter1-rack.*-server.*` pattern, e.g. `node-datacenter1-rack2-server42` - diff --git a/pkg/nfd-master/nfd-master.go b/pkg/nfd-master/nfd-master.go index 16918c7406..84e31fdb57 100644 --- a/pkg/nfd-master/nfd-master.go +++ b/pkg/nfd-master/nfd-master.go @@ -95,6 +95,7 @@ type Args struct { LabelWhiteList utils.RegexpVal FeatureRulesController bool NoPublish bool + NoTaint bool Port int Prune bool VerifyNodeName bool @@ -445,14 +446,15 @@ func (m *nfdMaster) SetLabels(c context.Context, r *pb.SetLabelsRequest) (*pb.Se klog.Errorf("failed to advertise labels: %v", err) return &pb.SetLabelsReply{}, err } - // Set NodeFeatureRule provided taints - if mustTaint { - labelReply, err := m.SetTaints(c, r) - if err != nil { - return labelReply, err + if !m.args.NoTaint { + // Set NodeFeatureRule provided taints + if mustTaint { + labelReply, err := m.SetTaints(c, r) + if err != nil { + return labelReply, err + } } } - } return &pb.SetLabelsReply{}, nil }