This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit c0a1c9e644a936f658f32e84474dd39888931618
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Fri Jun 28 15:40:40 2024 +0200

    fix(kustomize): support multiple operators
    
    Adding a suffix to ClusterRoleBindings
---
 docs/modules/ROOT/pages/installation/advanced/multi.adoc | 9 +++++++++
 e2e/support/test_support.go                              | 1 +
 e2e/support/test_util.go                                 | 1 +
 pkg/resources/config/rbac/descoped/kustomization.yaml    | 1 +
 script/Makefile                                          | 3 +++
 5 files changed, 15 insertions(+)

diff --git a/docs/modules/ROOT/pages/installation/advanced/multi.adoc 
b/docs/modules/ROOT/pages/installation/advanced/multi.adoc
index 2fbd1121a..13eeac70c 100644
--- a/docs/modules/ROOT/pages/installation/advanced/multi.adoc
+++ b/docs/modules/ROOT/pages/installation/advanced/multi.adoc
@@ -46,6 +46,15 @@ operator id:
 kubectl annotate integration timer-to-log 
camel.apache.org/operator.id=operator-2 --overwrite
 ----
 
+[[advanced-installation-caveat]]
+== Installation caveat
+
+In order to install more than one operator globally, you may need to change 
the ClusterRoleBindings to let more than one operator to have the RBAC set 
consistently. If you use a Kustomize installation approach, for example, you 
need to execute the following procedure to rename the roles and not conflicting 
between each other:
+
+```
+cd /install/base/config/rbac/descoped && kustomize edit set namesuffix -- 
-$OPERATOR_ID
+```
+
 [[advanced-installation-integration-profile]]
 == Apply custom IntegrationProfile settings
 
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index e15a0bdd2..5c41ec0e1 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -396,6 +396,7 @@ func MakeWithContext(t *testing.T, rule string, args 
...string) *exec.Cmd {
        }
 
        args = append([]string{"-C", makeDir, rule}, args...)
+       fmt.Println("Running make with arguments:", args)
        return exec.Command("make", args...)
 }
 
diff --git a/e2e/support/test_util.go b/e2e/support/test_util.go
index 3dd954e1d..4d9585083 100644
--- a/e2e/support/test_util.go
+++ b/e2e/support/test_util.go
@@ -98,6 +98,7 @@ func InstallOperatorWithConf(t *testing.T, ctx 
context.Context, g *WithT, ns, op
        }
        makeRule := "install-k8s-ns"
        if global {
+               fmt.Printf("Preparing for global installation")
                makeRule = "install-k8s-global"
        }
        os.Setenv("CAMEL_K_TEST_MAKE_DIR", "../../")
diff --git a/pkg/resources/config/rbac/descoped/kustomization.yaml 
b/pkg/resources/config/rbac/descoped/kustomization.yaml
index 7eed13633..820543a84 100644
--- a/pkg/resources/config/rbac/descoped/kustomization.yaml
+++ b/pkg/resources/config/rbac/descoped/kustomization.yaml
@@ -36,3 +36,4 @@ resources:
 - operator-cluster-role-binding-podmonitors.yaml
 - operator-cluster-role-binding-strimzi.yaml
 - operator-cluster-role-binding.yaml
+nameSuffix: -my-operator
diff --git a/script/Makefile b/script/Makefile
index 9f99c543c..322edaf08 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -749,6 +749,9 @@ ifdef OPERATOR_ID
        @sed -i 's/name: .*/name: $(OPERATOR_ID)/' 
$(KUST_TMP)/install/overlays/platform/integration-platform.yaml
        cd $(KUST_TMP)/install/overlays/platform/ && kustomize edit add 
annotation camel.apache.org/operator.id:$(OPERATOR_ID)
        @sed -i 's/value: .*/value: $(OPERATOR_ID)/' 
$(KUST_TMP)/$(KUSTOMIZE_DIR)/patch-operator-id.yaml
+       @echo "INFO: adding a suffix for ClusterRoleBindings $(OPERATOR_ID)"
+       cd $(KUST_TMP)/install/base/config/rbac/descoped && kustomize edit set 
namesuffix -- -$(OPERATOR_ID)
+       cd $(KUST_TMP)/install/base/config/rbac/openshift/descoped && kustomize 
edit set namesuffix -- -$(OPERATOR_ID)
 else
        @echo "INFO: no operator ID variable \"OPERATOR_ID\" provided. Keeping 
default."
 endif

Reply via email to