You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/06/08 12:51:37 UTC
[GitHub] [camel-k] astefanutti commented on a change in pull request #2284: Creates alternative kustomize installer for installation of the camel-k operator
astefanutti commented on a change in pull request #2284:
URL: https://github.com/apache/camel-k/pull/2284#discussion_r646367336
##########
File path: .github/workflows/builder.yml
##########
@@ -32,12 +32,6 @@ on:
branches:
- main
- "release-*"
- paths-ignore:
Review comment:
Is that removal intentional? I fail to see the reason for this.
##########
File path: config/Makefile
##########
@@ -0,0 +1,376 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Allows for resources to be loaded from outside the root location of
+# the kustomize config file. Ensures that resource don't need to be
+# copied around the file system.
+#
+# See https://kubectl.docs.kubernetes.io/faq/kustomize
+#
+KOPTIONS := --load-restrictor LoadRestrictionsNone
+
+#
+# Include the main camel-k Makefile containing
+# basic common recipes like kustomize and vars
+# like VERSION
+#
+include script/Makefile
+
+#
+# Vars that can be overridden by external env vars
+#
+DEBUG ?= false
+TAG ?= $(VERSION)
+NAMESPACE ?= camel-k
+
+# Image pull policy: [IfNotPresent|Always]
+IMAGE_PULL_POLICY ?= IfNotPresent
+# Global: [true|false]
+# - On setup: will promote roles and bindings to cluster-level
+# - On operator: set namespace to all using WATCH_NAMESPACE env var
+GLOBAL ?= false
+# Monitoring: [true|false]
+# - On operator: will add the prometheus resources to install
+MONITORING ?= false
+# Monitoring Port: integer
+MONITORING_PORT ?= 8080
+# Health Port: integer
+HEALTH_PORT ?= 8081
+
+RBAC_KUBE := rbac/kubernetes
+RBAC_OS := rbac/openshift
+RBAC_CLUSTER := cluster
+RBAC_GLOBAL := global
+INFRASTRUCTURE := infrastructure
+YAML := yaml
+
+OP_PATCHES := ./operator/patches
+PLATFORM_PATCHES := ./platform/patches
+PLACEHOLDER := placeholder
+IMAGE_PULL_POLICY_PATCH := image-pull-policy-always-patch
+WATCH_NAMESPACE_PATCH := watch-namespace-global-patch
+PORTS_PATCH := ports-patch
+INT_PLATFORM_PATCH := integration-platform-patch
+
+#
+# Macro for editing kustomization to define
+# the image reference
+#
+# Parameter: directory of the kustomization.yaml
+#
+define set-kustomize-image
+ $(if $(filter $(DEFAULT_IMAGE),$(IMAGE_NAME):$(TAG)),,\
+ @cd $(1) && $(KUSTOMIZE) edit set image $(DEFAULT_IMAGE)=$(IMAGE_NAME):$(TAG))
+endef
+
+#
+# Macro for editing kustomization to define
+# the namespace
+#
+# Parameter: directory of the kustomization.yaml
+#
+define set-kustomize-namespace
+ @cd $(1) && $(KUSTOMIZE) edit set namespace $(NAMESPACE)
+endef
+
+#
+# Macro for swapping a resource directory to an alternative directory
+#
+# Parameters:
+# * directory of the kustomization.yaml
+# * source directory
+# * target directory
+#
+define swap-rbac
+ @cd $(1) && \
+ $(KUSTOMIZE) edit remove resource ../$(2) && \
+ $(KUSTOMIZE) edit add resource ../$(3)
+endef
+
+#
+# Add or remove a patch on a kustomization.yaml
+# targetting the deployment resource
+#
+# Parameters:
+# * directory of the kustomization.yaml
+# * [add, remove]
+# * path of patch
+#
+define add-remove-deployment-patch
+ @cd $(1) && \
+ $(KUSTOMIZE) edit $(2) patch --path patches/$(3) --kind Deployment --name camel-k-operator
+endef
+
+#
+# Macro for adding / removing the prometheus resources for monitoring
+#
+define add-remove-operator-monitoring
+ cd $(1) && \
+ $(KUSTOMIZE) edit $(2) resource ../prometheus
+endef
+
+.PHONY: have-platform check_admin setup-cluster .setup-kubernetes .setup-openshift setup
+
+#
+# Determine the platform of the cluster based on
+# either the use of querying through a go-client
+# or using an installed client, ie. oc or kubectl
+#
+find-platform:
+ifndef PLATFORM
+PLATFORM=$(shell script/check_platform.sh)
+endif
+
+#
+# Checks if the cluster platform has been defined correctly either by the user
+# or by the platform_check script.
+#
+have-platform: find-platform
+ifeq ($(PLATFORM),openshift)
+ @echo Platform identified as 'openshift'
+else ifeq ($(PLATFORM),kubernetes)
+ @echo Platform identified as 'kubernetes'
+else
+ @echo "****"
+ @echo "**** ERROR: Cannot continue as cluster platform cannot be identified ****"
+ @echo "****"
+ @exit 1
+endif
+
+#
+# Checks if the cluster user has the necessary privileges to be a cluster-admin
+# In this case if the user can list the CRDs then probably a cluster-admin
+#
+check-admin: kubectl
+ @output=$$(kubectl get crd 2>&1) || (echo "****" && echo "**** ERROR: Cannot continue as user is not a Cluster-Admin ****" && echo "****"; exit 1)
+
+#
+# Setup the cluster installation by installing crds and cluster roles.
+#
+# Will either call setup-cluster-openshift (then setup-cluster-kubernetes) or
+# setup-cluster-kubernetes depending on the identity of the cluster
+#
+# PARAMETERS:
+# NAMESPACE: Sets the namespace for the resources
+# PLATFORM: Override the discovered platform, if required
+# DEBUG: true - Prints the resources to be applied instead of applying them
+#
+setup-cluster: have-platform kustomize kubectl check-admin
+# Set the namespace in the setup-cluster kustomization yaml
+ @$(call set-kustomize-namespace,$@)
+#
+#
+ifeq ($(PLATFORM), openshift)
+ @cd $@ && $(KUSTOMIZE) edit add resource ../$(RBAC_OS)-$(RBAC_CLUSTER)
+endif
+#
+# Build the resources
+# Post-process ClusterRoleBindings to fix the namespace in the refs (not yet handled by kustomize)
+# Either apply to the cluster or output to CLI
+#
+ifeq ($(DEBUG), false)
+ @$(KUSTOMIZE) build $(KOPTIONS) $@ | \
+ sed 's/$(PLACEHOLDER)/$(NAMESPACE)/' | \
+ kubectl apply -f -
+else
+ @$(KUSTOMIZE) build $(KOPTIONS) $@ | \
+ sed 's/$(PLACEHOLDER)/$(NAMESPACE)/'
+endif
+
+#
+# Modify the rbac/kubernetes resource definition depending on GLOBAL
+#
+.setup-kubernetes:
+# Resets back to default by removing any reference to rbac/openshift
+ @cd setup && \
+ $(KUSTOMIZE) edit remove resource ../$(RBAC_OS) && \
+ $(KUSTOMIZE) edit remove resource ../$(RBAC_OS)-$(RBAC_GLOBAL)
+ifeq ($(GLOBAL),true)
+ @echo "****"
+ @echo "**** GLOBAL requires a user with cluster-admin privileges ****"
+ @echo "****"
+ @$(MAKE) -s check-admin
+ @$(call swap-rbac,setup,"$(RBAC_KUBE)","$(RBAC_KUBE)-$(RBAC_GLOBAL)")
+else
+ @$(call swap-rbac,setup,"$(RBAC_KUBE)-$(RBAC_GLOBAL)","$(RBAC_KUBE)")
+endif
+
+#
+# Add in the rbac role designated in infrastructure
+# Modify the rbac/openshift resource definition depending on GLOBAL
+#
+.setup-openshift: .setup-kubernetes
+ @cd $(INFRASTRUCTURE) && $(KUSTOMIZE) edit add resource $(RBAC_OS)
+ifeq ($(GLOBAL),true)
+ @echo "****"
+ @echo "**** GLOBAL requires a user with cluster-admin privileges ****"
+ @echo "****"
+ @$(MAKE) -s check-admin
+ @$(call swap-rbac,setup,"$(RBAC_OS)","$(RBAC_OS)-$(RBAC_GLOBAL)")
+else
+ @$(call swap-rbac,setup,"$(RBAC_OS)-$(RBAC_GLOBAL)","$(RBAC_OS)")
+endif
+
+#
+# Setup the installation by installing roles and granting
+# privileges for the installing operator. Although a cluster-admin
+# is not required a suitably privieged user is in order to create all
Review comment:
nit: `privieged` -> `privileged`
##########
File path: config/rbac/kubernetes/operator-role-binding-events.yaml
##########
@@ -21,6 +21,8 @@ metadata:
name: camel-k-operator-events
labels:
app: "camel-k"
+ annotations:
+ can-promote: "true"
Review comment:
Is this really needed? It seems pretty much all the Roles and RoleBindings are eligible to cluster-wide promotion. At least, if few of them are not eligible, it may be more appropriate to have an "exclude" annotation.
##########
File path: e2e/common/kustomize/operator_test.go
##########
@@ -0,0 +1,89 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package kustomize
+
+import (
+ "fmt"
+ "testing"
+
+ . "github.com/apache/camel-k/e2e/support"
+ . "github.com/onsi/gomega"
+)
+
+func TestBasicOperator(t *testing.T) {
+ defer Uninstall()
+
+ WithNewTestNamespace(t, func(ns string) {
+ ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
+ ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns)))
+ ExecMake(t, Make("operator", fmt.Sprintf("NAMESPACE=%s", ns)))
+
+ Eventually(OperatorPod(ns)).ShouldNot(BeNil())
+ })
+}
+
+func TestAlternativeImageOperator(t *testing.T) {
+ defer Uninstall()
+
+ WithNewTestNamespace(t, func(ns string) {
+
+ ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
+ ExecMake(t, Make("setup", fmt.Sprintf("NAMESPACE=%s", ns)))
+
+ newImage := "quay.io/kameltest/kamel-operator"
+ newTag := "1.1.1"
+ ExecMake(t, Make("operator", fmt.Sprintf("IMAGE_NAME=%s", newImage), fmt.Sprintf("TAG=%s", newTag), fmt.Sprintf("NAMESPACE=%s", ns)))
+
+ Eventually(OperatorImage(ns)).Should(Equal(fmt.Sprintf("%s:%s", newImage, newTag)))
+ })
+}
+
+func TestGlobalOperator(t *testing.T) {
+ defer Uninstall()
+
+ WithNewTestNamespace(t, func(ns string) {
+ ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns), "GLOBAL=true"))
Review comment:
What `GLOBAL` does for cluster setup? I don't see it as parameter of the `setup-cluster` target.
##########
File path: config/infrastructure/rbac/kubernetes/builder-role-kubernetes.yaml
##########
@@ -18,7 +18,7 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
- name: camel-k-builder
+ name: camel-k-builder-kubernetes
Review comment:
Is this really required, to have different names? Ultimately, only one will be applied.
##########
File path: config/infrastructure/rbac/kubernetes/builder-role-binding-kubernetes.yaml
##########
@@ -0,0 +1,30 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+kind: RoleBinding
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+ name: camel-k-builder-kubernetes
+ labels:
Review comment:
Ideally this should be added with `commonLabels`, but I'm not sure the `kamel install` command adds common labels consistently?
##########
File path: e2e/common/kustomize/operator_test.go
##########
@@ -0,0 +1,89 @@
+// +build integration
+
+// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
+
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package kustomize
+
+import (
+ "fmt"
+ "testing"
+
+ . "github.com/apache/camel-k/e2e/support"
+ . "github.com/onsi/gomega"
+)
+
+func TestBasicOperator(t *testing.T) {
+ defer Uninstall()
+
+ WithNewTestNamespace(t, func(ns string) {
+ ExecMake(t, Make("setup-cluster", fmt.Sprintf("NAMESPACE=%s", ns)))
Review comment:
Cluster setup is already done in the workflow. One option is to remove cluster setup from the e2e tests, to be consistent with the other tests. Or we can create a dedicated workflow and call the cluster setup from the workflow definition.
##########
File path: config/rbac/kubernetes/kustomization.yaml
##########
@@ -15,22 +15,26 @@
# limitations under the License.
# ---------------------------------------------------------------------------
+#
+# rbac resources applicable for all kubernetes platforms
+#
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+
resources:
+- user-global-kamelet-viewer-role.yaml
Review comment:
I think these are created by the operator itself and not at installation time.
##########
File path: config/Makefile
##########
@@ -0,0 +1,376 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Allows for resources to be loaded from outside the root location of
+# the kustomize config file. Ensures that resource don't need to be
+# copied around the file system.
+#
+# See https://kubectl.docs.kubernetes.io/faq/kustomize
+#
+KOPTIONS := --load-restrictor LoadRestrictionsNone
+
+#
+# Include the main camel-k Makefile containing
+# basic common recipes like kustomize and vars
+# like VERSION
+#
+include script/Makefile
+
+#
+# Vars that can be overridden by external env vars
+#
+DEBUG ?= false
+TAG ?= $(VERSION)
+NAMESPACE ?= camel-k
+
+# Image pull policy: [IfNotPresent|Always]
+IMAGE_PULL_POLICY ?= IfNotPresent
+# Global: [true|false]
+# - On setup: will promote roles and bindings to cluster-level
+# - On operator: set namespace to all using WATCH_NAMESPACE env var
+GLOBAL ?= false
+# Monitoring: [true|false]
+# - On operator: will add the prometheus resources to install
+MONITORING ?= false
+# Monitoring Port: integer
+MONITORING_PORT ?= 8080
+# Health Port: integer
+HEALTH_PORT ?= 8081
+
+RBAC_KUBE := rbac/kubernetes
+RBAC_OS := rbac/openshift
+RBAC_CLUSTER := cluster
+RBAC_GLOBAL := global
+INFRASTRUCTURE := infrastructure
+YAML := yaml
+
+OP_PATCHES := ./operator/patches
+PLATFORM_PATCHES := ./platform/patches
+PLACEHOLDER := placeholder
+IMAGE_PULL_POLICY_PATCH := image-pull-policy-always-patch
+WATCH_NAMESPACE_PATCH := watch-namespace-global-patch
+PORTS_PATCH := ports-patch
+INT_PLATFORM_PATCH := integration-platform-patch
+
+#
+# Macro for editing kustomization to define
+# the image reference
+#
+# Parameter: directory of the kustomization.yaml
+#
+define set-kustomize-image
+ $(if $(filter $(DEFAULT_IMAGE),$(IMAGE_NAME):$(TAG)),,\
+ @cd $(1) && $(KUSTOMIZE) edit set image $(DEFAULT_IMAGE)=$(IMAGE_NAME):$(TAG))
+endef
+
+#
+# Macro for editing kustomization to define
+# the namespace
+#
+# Parameter: directory of the kustomization.yaml
+#
+define set-kustomize-namespace
+ @cd $(1) && $(KUSTOMIZE) edit set namespace $(NAMESPACE)
+endef
+
+#
+# Macro for swapping a resource directory to an alternative directory
+#
+# Parameters:
+# * directory of the kustomization.yaml
+# * source directory
+# * target directory
+#
+define swap-rbac
+ @cd $(1) && \
+ $(KUSTOMIZE) edit remove resource ../$(2) && \
+ $(KUSTOMIZE) edit add resource ../$(3)
+endef
+
+#
+# Add or remove a patch on a kustomization.yaml
+# targetting the deployment resource
+#
+# Parameters:
+# * directory of the kustomization.yaml
+# * [add, remove]
+# * path of patch
+#
+define add-remove-deployment-patch
+ @cd $(1) && \
+ $(KUSTOMIZE) edit $(2) patch --path patches/$(3) --kind Deployment --name camel-k-operator
+endef
+
+#
+# Macro for adding / removing the prometheus resources for monitoring
+#
+define add-remove-operator-monitoring
+ cd $(1) && \
+ $(KUSTOMIZE) edit $(2) resource ../prometheus
+endef
+
+.PHONY: have-platform check_admin setup-cluster .setup-kubernetes .setup-openshift setup
+
+#
+# Determine the platform of the cluster based on
+# either the use of querying through a go-client
+# or using an installed client, ie. oc or kubectl
+#
+find-platform:
+ifndef PLATFORM
+PLATFORM=$(shell script/check_platform.sh)
+endif
+
+#
+# Checks if the cluster platform has been defined correctly either by the user
+# or by the platform_check script.
+#
+have-platform: find-platform
+ifeq ($(PLATFORM),openshift)
+ @echo Platform identified as 'openshift'
+else ifeq ($(PLATFORM),kubernetes)
+ @echo Platform identified as 'kubernetes'
+else
+ @echo "****"
+ @echo "**** ERROR: Cannot continue as cluster platform cannot be identified ****"
+ @echo "****"
+ @exit 1
+endif
+
+#
+# Checks if the cluster user has the necessary privileges to be a cluster-admin
+# In this case if the user can list the CRDs then probably a cluster-admin
+#
+check-admin: kubectl
+ @output=$$(kubectl get crd 2>&1) || (echo "****" && echo "**** ERROR: Cannot continue as user is not a Cluster-Admin ****" && echo "****"; exit 1)
+
+#
+# Setup the cluster installation by installing crds and cluster roles.
+#
+# Will either call setup-cluster-openshift (then setup-cluster-kubernetes) or
+# setup-cluster-kubernetes depending on the identity of the cluster
+#
+# PARAMETERS:
+# NAMESPACE: Sets the namespace for the resources
+# PLATFORM: Override the discovered platform, if required
+# DEBUG: true - Prints the resources to be applied instead of applying them
+#
+setup-cluster: have-platform kustomize kubectl check-admin
+# Set the namespace in the setup-cluster kustomization yaml
+ @$(call set-kustomize-namespace,$@)
Review comment:
I think the culprit comes from the ClusterRoleBinding, that requires knowledge about the namespace where the operator is to be installed. I'd be inclined to think ClusterRoleBinding resources should be created during the setup, not the cluster setup, which is what the `kamel install` command does. I may see it's for the ability to install the operator as standard user, but in practice, installing the operator requires cluster admin. Plus, that requires to run the cluster setup each time you install the operator in different namespaces.
##########
File path: config/Makefile
##########
@@ -0,0 +1,376 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Allows for resources to be loaded from outside the root location of
+# the kustomize config file. Ensures that resource don't need to be
+# copied around the file system.
+#
+# See https://kubectl.docs.kubernetes.io/faq/kustomize
+#
+KOPTIONS := --load-restrictor LoadRestrictionsNone
+
+#
+# Include the main camel-k Makefile containing
+# basic common recipes like kustomize and vars
+# like VERSION
+#
+include script/Makefile
+
+#
+# Vars that can be overridden by external env vars
+#
+DEBUG ?= false
+TAG ?= $(VERSION)
+NAMESPACE ?= camel-k
+
+# Image pull policy: [IfNotPresent|Always]
+IMAGE_PULL_POLICY ?= IfNotPresent
+# Global: [true|false]
+# - On setup: will promote roles and bindings to cluster-level
+# - On operator: set namespace to all using WATCH_NAMESPACE env var
+GLOBAL ?= false
+# Monitoring: [true|false]
+# - On operator: will add the prometheus resources to install
+MONITORING ?= false
+# Monitoring Port: integer
+MONITORING_PORT ?= 8080
+# Health Port: integer
+HEALTH_PORT ?= 8081
+
+RBAC_KUBE := rbac/kubernetes
+RBAC_OS := rbac/openshift
+RBAC_CLUSTER := cluster
+RBAC_GLOBAL := global
+INFRASTRUCTURE := infrastructure
+YAML := yaml
+
+OP_PATCHES := ./operator/patches
+PLATFORM_PATCHES := ./platform/patches
+PLACEHOLDER := placeholder
+IMAGE_PULL_POLICY_PATCH := image-pull-policy-always-patch
+WATCH_NAMESPACE_PATCH := watch-namespace-global-patch
+PORTS_PATCH := ports-patch
+INT_PLATFORM_PATCH := integration-platform-patch
+
+#
+# Macro for editing kustomization to define
+# the image reference
+#
+# Parameter: directory of the kustomization.yaml
+#
+define set-kustomize-image
+ $(if $(filter $(DEFAULT_IMAGE),$(IMAGE_NAME):$(TAG)),,\
+ @cd $(1) && $(KUSTOMIZE) edit set image $(DEFAULT_IMAGE)=$(IMAGE_NAME):$(TAG))
+endef
+
+#
+# Macro for editing kustomization to define
+# the namespace
+#
+# Parameter: directory of the kustomization.yaml
+#
+define set-kustomize-namespace
+ @cd $(1) && $(KUSTOMIZE) edit set namespace $(NAMESPACE)
+endef
+
+#
+# Macro for swapping a resource directory to an alternative directory
+#
+# Parameters:
+# * directory of the kustomization.yaml
+# * source directory
+# * target directory
+#
+define swap-rbac
+ @cd $(1) && \
+ $(KUSTOMIZE) edit remove resource ../$(2) && \
+ $(KUSTOMIZE) edit add resource ../$(3)
+endef
+
+#
+# Add or remove a patch on a kustomization.yaml
+# targetting the deployment resource
+#
+# Parameters:
+# * directory of the kustomization.yaml
+# * [add, remove]
+# * path of patch
+#
+define add-remove-deployment-patch
+ @cd $(1) && \
+ $(KUSTOMIZE) edit $(2) patch --path patches/$(3) --kind Deployment --name camel-k-operator
+endef
+
+#
+# Macro for adding / removing the prometheus resources for monitoring
+#
+define add-remove-operator-monitoring
+ cd $(1) && \
+ $(KUSTOMIZE) edit $(2) resource ../prometheus
+endef
+
+.PHONY: have-platform check_admin setup-cluster .setup-kubernetes .setup-openshift setup
+
+#
+# Determine the platform of the cluster based on
+# either the use of querying through a go-client
+# or using an installed client, ie. oc or kubectl
+#
+find-platform:
+ifndef PLATFORM
+PLATFORM=$(shell script/check_platform.sh)
+endif
+
+#
+# Checks if the cluster platform has been defined correctly either by the user
+# or by the platform_check script.
+#
+have-platform: find-platform
+ifeq ($(PLATFORM),openshift)
+ @echo Platform identified as 'openshift'
+else ifeq ($(PLATFORM),kubernetes)
+ @echo Platform identified as 'kubernetes'
+else
+ @echo "****"
+ @echo "**** ERROR: Cannot continue as cluster platform cannot be identified ****"
+ @echo "****"
+ @exit 1
+endif
+
+#
+# Checks if the cluster user has the necessary privileges to be a cluster-admin
+# In this case if the user can list the CRDs then probably a cluster-admin
+#
+check-admin: kubectl
+ @output=$$(kubectl get crd 2>&1) || (echo "****" && echo "**** ERROR: Cannot continue as user is not a Cluster-Admin ****" && echo "****"; exit 1)
+
+#
+# Setup the cluster installation by installing crds and cluster roles.
+#
+# Will either call setup-cluster-openshift (then setup-cluster-kubernetes) or
+# setup-cluster-kubernetes depending on the identity of the cluster
+#
+# PARAMETERS:
+# NAMESPACE: Sets the namespace for the resources
+# PLATFORM: Override the discovered platform, if required
+# DEBUG: true - Prints the resources to be applied instead of applying them
+#
+setup-cluster: have-platform kustomize kubectl check-admin
+# Set the namespace in the setup-cluster kustomization yaml
+ @$(call set-kustomize-namespace,$@)
Review comment:
Is this really needed?
##########
File path: config/manifests/bases/camel-k.clusterserviceversion.yaml
##########
@@ -151,6 +151,7 @@ spec:
minKubeVersion: 1.11.0
provider:
name: The Apache Software Foundation
+ replaces: camel-k-operator.v1.4.0
Review comment:
Is there an easy way for developers to remove that field? It's been left empty to support the local generation of the OLM bundle, in which case no previous version is replaced. If we are to add it, that kinds of break that use case.
##########
File path: e2e/builder/build_test.go
##########
@@ -40,7 +40,7 @@ func TestKitKnativeFullBuild(t *testing.T) {
func doKitFullBuild(t *testing.T, name string, dependencies ...string) {
WithNewTestNamespace(t, func(ns string) {
- Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+ Expect(Kamel("install", "-n", ns, "--olm=false").Execute()).To(Succeed())
Review comment:
Is that change intentional?
##########
File path: config/Makefile
##########
@@ -0,0 +1,376 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Allows for resources to be loaded from outside the root location of
+# the kustomize config file. Ensures that resource don't need to be
+# copied around the file system.
+#
+# See https://kubectl.docs.kubernetes.io/faq/kustomize
+#
+KOPTIONS := --load-restrictor LoadRestrictionsNone
+
+#
+# Include the main camel-k Makefile containing
+# basic common recipes like kustomize and vars
+# like VERSION
+#
+include script/Makefile
+
+#
+# Vars that can be overridden by external env vars
+#
+DEBUG ?= false
Review comment:
Would `DRY_RUN` be more meaningful?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org