This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 654e039c77e5fbeb3f1bcb1ae8bf8e9e367a7110 Author: Pasquale Congiusti <[email protected]> AuthorDate: Fri Mar 26 12:51:14 2021 +0100 feat(operator): provide operator NodeSelector Adding a flag to allow defining any NodeSelector during regular installation procedure --- pkg/cmd/install.go | 5 ++++- pkg/install/operator.go | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 0adbac4..e3ec076 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -128,6 +128,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO // Pod settings cmd.Flags().StringArrayP("toleration", "", nil, "Add a Toleration to the operator Pod") + cmd.Flags().StringArrayP("node-selector", "", nil, "Add a NodeSelector to the operator Pod") // save cmd.Flags().Bool("save", false, "Save the install parameters into the default kamel configuration file (kamel-config.yaml)") @@ -175,6 +176,7 @@ type installCmdOptions struct { Properties []string `mapstructure:"properties"` TraitProfile string `mapstructure:"trait-profile"` Tolerations []string `mapstructure:"tolerations"` + NodeSelectors []string `mapstructure:"node-selectors"` HTTPProxySecret string `mapstructure:"http-proxy-secret"` registry v1.IntegrationPlatformRegistrySpec @@ -272,7 +274,8 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error { Enabled: o.Monitoring, Port: o.MonitoringPort, }, - Tolerations: o.Tolerations, + Tolerations: o.Tolerations, + NodeSelectors: o.NodeSelectors, } err = install.OperatorOrCollect(o.Context, c, cfg, collection, o.Force) if err != nil { diff --git a/pkg/install/operator.go b/pkg/install/operator.go index 1fc6cf7..3442c82 100644 --- a/pkg/install/operator.go +++ b/pkg/install/operator.go @@ -55,6 +55,7 @@ type OperatorConfiguration struct { Health OperatorHealthConfiguration Monitoring OperatorMonitoringConfiguration Tolerations []string + NodeSelectors []string } // OperatorHealthConfiguration -- @@ -99,6 +100,18 @@ func OperatorOrCollect(ctx context.Context, c client.Client, cfg OperatorConfigu } } + if cfg.NodeSelectors != nil { + if d, ok := o.(*appsv1.Deployment); ok { + if d.Labels["camel.apache.org/component"] == "operator" { + nodeSelector, err := kubernetes.GetNodeSelectors(cfg.NodeSelectors) + if err != nil { + fmt.Println("Warning: could not parse the configured node selectors!") + } + d.Spec.Template.Spec.NodeSelector = nodeSelector + } + } + } + if d, ok := o.(*appsv1.Deployment); ok { if d.Labels["camel.apache.org/component"] == "operator" { // Metrics endpoint port
