You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/04/12 11:59:05 UTC
[camel-k] 04/05: feat(operator): provide OLM NodeSelector
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 dd2ca05e181612ebbf5ecad67a1a3f15d5120733
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Mar 26 12:51:50 2021 +0100
feat(operator): provide OLM NodeSelector
Adding a flag to allow defining any NodeSelector during OLM installation procedure
---
pkg/cmd/install.go | 2 +-
pkg/util/olm/operator.go | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index e3ec076..1692c15 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -223,7 +223,7 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
if installViaOLM {
fmt.Fprintln(cobraCmd.OutOrStdout(), "OLM is available in the cluster")
var installed bool
- if installed, err = olm.Install(o.Context, olmClient, o.Namespace, o.Global, o.olmOptions, collection, o.Tolerations); err != nil {
+ if installed, err = olm.Install(o.Context, olmClient, o.Namespace, o.Global, o.olmOptions, collection, o.Tolerations, o.NodeSelectors); err != nil {
return err
}
if !installed {
diff --git a/pkg/util/olm/operator.go b/pkg/util/olm/operator.go
index 896b241..74970d0 100644
--- a/pkg/util/olm/operator.go
+++ b/pkg/util/olm/operator.go
@@ -138,7 +138,7 @@ func HasPermissionToInstall(ctx context.Context, client client.Client, namespace
}
// Install creates a subscription for the OLM package
-func Install(ctx context.Context, client client.Client, namespace string, global bool, options Options, collection *kubernetes.Collection, tolerations []string) (bool, error) {
+func Install(ctx context.Context, client client.Client, namespace string, global bool, options Options, collection *kubernetes.Collection, tolerations []string, nodeSelectors []string) (bool, error) {
options = fillDefaults(options)
if installed, err := IsOperatorInstalled(ctx, client, namespace, global, options); err != nil {
return false, err
@@ -171,6 +171,10 @@ func Install(ctx context.Context, client client.Client, namespace string, global
if err != nil {
return false, errors.Wrap(err, fmt.Sprintf("could not set tolerations"))
}
+ err = maybeSetNodeSelectors(&sub, nodeSelectors)
+ if err != nil {
+ return false, errors.Wrap(err, fmt.Sprintf("could not set node selectors"))
+ }
if collection != nil {
collection.Add(&sub)
@@ -216,6 +220,17 @@ func maybeSetTolerations(sub *operatorsv1alpha1.Subscription, tolArray []string)
return nil
}
+func maybeSetNodeSelectors(sub *operatorsv1alpha1.Subscription, nsArray []string) error {
+ if nsArray != nil {
+ nodeSelectors, err := kubernetes.GetNodeSelectors(nsArray)
+ if err != nil {
+ return err
+ }
+ sub.Spec.Config.NodeSelector = nodeSelectors
+ }
+ return nil
+}
+
// Uninstall removes CSV and subscription from the namespace
func Uninstall(ctx context.Context, client client.Client, namespace string, global bool, options Options) error {
sub, err := findSubscription(ctx, client, namespace, global, options)