diff --git a/config/manifests/bases/camel-k.clusterserviceversion.yaml b/config/manifests/bases/camel-k.clusterserviceversion.yaml index db02c16a40..8bcc75e7ec 100644 --- a/config/manifests/bases/camel-k.clusterserviceversion.yaml +++ b/config/manifests/bases/camel-k.clusterserviceversion.yaml @@ -23,7 +23,7 @@ metadata: categories: Integration & Delivery certified: "false" containerImage: docker.io/apache/camel-k:2.2.0-SNAPSHOT - createdAt: 2023-10-24T07:48:33Z + createdAt: 2023-12-15T09:52:30Z description: Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers. operators.operatorframework.io/builder: operator-sdk-v1.16.0 @@ -87,10 +87,12 @@ spec: Apache Camel K ============== - Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers. + Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers: + the easiest way to build and manage your Camel applications on Kubernetes. ## Installation + You may need to specify the container registry where to store the container images created for the Camel applications. To start using Camel K, install the operator and then create the following `IntegrationPlatform`: ``` apiVersion: camel.apache.org/v1 @@ -99,34 +101,39 @@ spec: name: camel-k labels: app: "camel-k" + spec: + build: + registry: + address: docker.io/my-org ``` - An `IntegrationPlatform` resource is automatically created by default on OpenShift, so you can skip this step. - Also, You can edit the `IntegrationPlatform`, to configure Camel K. - The configuration from the `IntegrationPlatform` will apply to the Camel integrations created in the same namespace/project. + An `IntegrationPlatform` resource is automatically created by default on OpenShift, so you can skip this step when using Openshift cluster. ## Running an Integration - After the initial setup, you can run a Camel integration on the cluster by creating an example `Integration`, e.g.: + Run a Camel application on the cluster by creating a sample `Integration`, e.g.: ``` apiVersion: camel.apache.org/v1 kind: Integration metadata: - name: example + annotations: + camel.apache.org/operator.id: camel-k + name: test spec: - sources: - - name: Example.java - content: | - import org.apache.camel.builder.RouteBuilder; - - public class Example extends RouteBuilder { - @Override - public void configure() throws Exception { - from("timer:tick") - .setBody(constant("Hello World!")) - .to("log:info?skipBodyLineSeparator=false"); - } - } + flows: + - from: + parameters: + period: "1000" + steps: + - setBody: + simple: Hello Camel from ${routeId} + - log: ${body} + uri: timer:yaml + ``` + Log the result of the running application: + ``` + kubectl wait --for=condition=ready integration test --timeout=180s + kubectl logs deployment/test -f ``` displayName: Camel K Operator icon: diff --git a/config/rbac/descoped/knative/kustomization.yaml b/config/rbac/descoped/knative/kustomization.yaml new file mode 100644 index 0000000000..34524d9d64 --- /dev/null +++ b/config/rbac/descoped/knative/kustomization.yaml @@ -0,0 +1,27 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +# +# rbac resources applicable for all kubernetes platforms - global operator +# +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- operator-cluster-role-knative.yaml +- operator-cluster-role-binding-knative.yaml + diff --git a/config/rbac/descoped/operator-cluster-role-binding-knative.yaml b/config/rbac/descoped/knative/operator-cluster-role-binding-knative.yaml similarity index 100% rename from config/rbac/descoped/operator-cluster-role-binding-knative.yaml rename to config/rbac/descoped/knative/operator-cluster-role-binding-knative.yaml diff --git a/config/rbac/descoped/operator-cluster-role-knative.yaml b/config/rbac/descoped/knative/operator-cluster-role-knative.yaml similarity index 100% rename from config/rbac/descoped/operator-cluster-role-knative.yaml rename to config/rbac/descoped/knative/operator-cluster-role-knative.yaml diff --git a/config/rbac/descoped/kustomization.yaml b/config/rbac/descoped/kustomization.yaml index ade2d46ba8..20ea57f67c 100644 --- a/config/rbac/descoped/kustomization.yaml +++ b/config/rbac/descoped/kustomization.yaml @@ -23,7 +23,6 @@ kind: Kustomization resources: - operator-cluster-role-events.yaml -- operator-cluster-role-knative.yaml - operator-cluster-role.yaml - operator-cluster-role-keda.yaml - operator-cluster-role-leases.yaml @@ -31,7 +30,6 @@ resources: - operator-cluster-role-strimzi.yaml - operator-cluster-role-binding-events.yaml - operator-cluster-role-binding-keda.yaml -- operator-cluster-role-binding-knative.yaml - operator-cluster-role-binding-leases.yaml - operator-cluster-role-binding-podmonitors.yaml - operator-cluster-role-binding-strimzi.yaml diff --git a/config/rbac/namespaced/knative/kustomization.yaml b/config/rbac/namespaced/knative/kustomization.yaml new file mode 100644 index 0000000000..281bd5f6e3 --- /dev/null +++ b/config/rbac/namespaced/knative/kustomization.yaml @@ -0,0 +1,26 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- + +# +# rbac resources applicable for all kubernetes platforms - namespaced operator +# +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- operator-role-knative.yaml +- operator-role-binding-knative.yaml diff --git a/config/rbac/namespaced/operator-role-binding-knative.yaml b/config/rbac/namespaced/knative/operator-role-binding-knative.yaml similarity index 97% rename from config/rbac/namespaced/operator-role-binding-knative.yaml rename to config/rbac/namespaced/knative/operator-role-binding-knative.yaml index 034baef7be..9264f3c4b1 100644 --- a/config/rbac/namespaced/operator-role-binding-knative.yaml +++ b/config/rbac/namespaced/knative/operator-role-binding-knative.yaml @@ -24,6 +24,7 @@ metadata: subjects: - kind: ServiceAccount name: camel-k-operator + namespace: placeholder roleRef: kind: Role name: camel-k-operator-knative diff --git a/config/rbac/namespaced/operator-role-knative.yaml b/config/rbac/namespaced/knative/operator-role-knative.yaml similarity index 100% rename from config/rbac/namespaced/operator-role-knative.yaml rename to config/rbac/namespaced/knative/operator-role-knative.yaml diff --git a/config/rbac/namespaced/kustomization.yaml b/config/rbac/namespaced/kustomization.yaml index 510beb4d57..c64b3e906c 100644 --- a/config/rbac/namespaced/kustomization.yaml +++ b/config/rbac/namespaced/kustomization.yaml @@ -23,7 +23,6 @@ kind: Kustomization resources: - operator-role-events.yaml -- operator-role-knative.yaml - operator-role.yaml - operator-role-keda.yaml - operator-role-leases.yaml @@ -31,7 +30,6 @@ resources: - operator-role-strimzi.yaml - operator-role-binding-events.yaml - operator-role-binding-keda.yaml -- operator-role-binding-knative.yaml - operator-role-binding-leases.yaml - operator-role-binding-podmonitors.yaml - operator-role-binding-strimzi.yaml diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index f13dbd7efa..017b36dfc2 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -1,6 +1,7 @@ * xref:installation/installation.adoc[Installation] -** xref:installation/advanced/maven.adoc[Configuring Maven] -** xref:installation/registry/registry.adoc[Configuring Registry] +** xref:installation/advanced/maven.adoc[Configure Maven] +** xref:installation/registry/registry.adoc[Configure Registry] +** xref:installation/knative.adoc[Configure Knative] ** xref:contributing/upgrade.adoc[Upgrade] ** xref:contributing/uninstalling.adoc[Uninstalling] ** xref:installation/advanced/advanced.adoc[Advanced] diff --git a/docs/modules/ROOT/pages/installation/knative.adoc b/docs/modules/ROOT/pages/installation/knative.adoc new file mode 100644 index 0000000000..24fca76120 --- /dev/null +++ b/docs/modules/ROOT/pages/installation/knative.adoc @@ -0,0 +1,42 @@ += Knative installation + +"https://knative.dev[Knative] is an Open-Source Enterprise-level solution to build Serverless and Event Driven Applications. The effort done in this project is a great complement to Camel K, which can leverage some feature offered by Knative. In particular, Camel K will be able to leverage "scale to 0" (hence, serverless) feature offered by Knative. + +NOTE: Knative is an optional configuration. It is not required to run Camel K. + +[[install-knative]] +== Knative roles configuration + +Camel K needs to have certain privileges to use the resources used by Knative. We have identified them, so, it follows a few configuration that you will need to apply in order to make Camel K work with Knative. + +NOTE: We assume you have already both the Knative operator and the Camel K operator up and running. If not, the first step is to install both operator. See the guide on xref:installation/installation.adoc[how to install Camel K] and the guide on https://knative.dev/docs/install/[how to install Knative] respectively. + +Once all the resources are installed in the cluster, you'll need to provide the required privileges for Camel K operator to work with Knative resources. + +NOTE: you will need `kustomize` CLI available. + +=== Global operator (descoped) + +```bash +git clone --depth 1 --branch v2.1.0 https://github.com/apache/camel-k.git +cd camel-k/config/rbac/descoped/knative +sed -i "s/namespace: placeholder/namespace: $OPERATOR_NAMESPACE/" operator-cluster-role-binding-knative.yaml +kustomize edit set namespace $OPERATOR_NAMESPACE +kubectl apply -k . +``` + +=== Namespaced operator + +```bash +git clone --depth 1 --branch v2.1.0 https://github.com/apache/camel-k.git +cd camel-k/config/rbac/namespaced/knative +sed -i "s/namespace: placeholder/namespace: $OPERATOR_NAMESPACE/" operator-role-binding-knative.yaml +kustomize edit set namespace $OPERATOR_NAMESPACE +kubectl apply -k . +``` + +NOTE: in this example we've used the released `2.1.0` version. Make sure to use the same version of your installed operator. + +As the installation procedure can vary depending on the cluster and the methodology you use (Helm, OLM, Kustomize, ...), feel free to customize in the way that it results more convenient. In the `/config/rbac/knative` you will already find the basic `kustomization.yaml` on top of which you may provide any further level of customization. + +From now on you should be able to run some Camel application leveraging Knative with Camel K (see https://github.com/apache/camel-k-examples/tree/main/generic-examples/knative[examples]). \ No newline at end of file diff --git a/e2e/knative/knative_test.go b/e2e/knative/knative_test.go index 56ce5d5ec2..54d2cd7e1c 100644 --- a/e2e/knative/knative_test.go +++ b/e2e/knative/knative_test.go @@ -24,6 +24,8 @@ package knative import ( "fmt" + "os/exec" + "path" "testing" "time" @@ -46,13 +48,13 @@ func TestKnative(t *testing.T) { t.Run("Service combo", func(t *testing.T) { Expect(KamelRunWithID(operatorID, ns, "files/knative2.groovy").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "knative2"), TestTimeoutLong).Should(Equal(v1.PodRunning)) - Eventually(IntegrationConditionStatus(ns, "knative2", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationConditionStatus(ns, "knative2", camelv1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(v1.ConditionTrue)) Expect(KamelRunWithID(operatorID, ns, "files/knative3.groovy").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "knative3"), TestTimeoutLong).Should(Equal(v1.PodRunning)) - Eventually(IntegrationConditionStatus(ns, "knative3", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationConditionStatus(ns, "knative3", camelv1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(v1.ConditionTrue)) Expect(KamelRunWithID(operatorID, ns, "files/knative1.groovy").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "knative1"), TestTimeoutLong).Should(Equal(v1.PodRunning)) - Eventually(IntegrationConditionStatus(ns, "knative1", camelv1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(v1.ConditionTrue)) + Eventually(IntegrationConditionStatus(ns, "knative1", camelv1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(v1.ConditionTrue)) // Correct logs Eventually(IntegrationLogs(ns, "knative1"), TestTimeoutMedium).Should(ContainSubstring("Received from 2: Hello from knative2")) Eventually(IntegrationLogs(ns, "knative1"), TestTimeoutMedium).Should(ContainSubstring("Received from 3: Hello from knative3")) @@ -142,6 +144,21 @@ func TestRunBroker(t *testing.T) { WithNewTestNamespaceWithKnativeBroker(t, func(ns string) { operatorID := fmt.Sprintf("camel-k-%s", ns) Expect(KamelInstallWithID(operatorID, ns, "--trait-profile", "knative").Execute()).To(Succeed()) + + // We must include namespace privileges to manage Knative objects + testDir := "../../" + kustomizeCmd := exec.Command("kustomize", "edit", "set", "namespace", ns) + kustomizeCmd.Dir = path.Join(testDir, "config/rbac/namespaced/knative") + ExpectExecSucceed(t, kustomizeCmd) + replaceORBKCmd := exec.Command( + "sed", "-i", fmt.Sprintf("s/namespace: .*/namespace: %s/", ns), "operator-role-binding-knative.yaml", + ) + replaceORBKCmd.Dir = path.Join(testDir, "config/rbac/namespaced/knative") + ExpectExecSucceed(t, replaceORBKCmd) + kubectlApplyCmd := exec.Command("kubectl", "apply", "-k", ".") + kubectlApplyCmd.Dir = path.Join(testDir, "config/rbac/namespaced/knative") + ExpectExecSucceed(t, kubectlApplyCmd) + Expect(KamelRunWithID(operatorID, ns, "files/knativeevt1.groovy").Execute()).To(Succeed()) Expect(KamelRunWithID(operatorID, ns, "files/knativeevt2.groovy").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "knativeevt1"), TestTimeoutLong).Should(Equal(v1.PodRunning)) diff --git a/e2e/knative/pod_test.go b/e2e/knative/pod_test.go index 64b39fda11..bb7d4e083a 100644 --- a/e2e/knative/pod_test.go +++ b/e2e/knative/pod_test.go @@ -39,10 +39,10 @@ func TestPodTraitWithKnative(t *testing.T) { Expect(KamelRunWithID(operatorID, ns, "files/podtest-knative2.groovy", "--pod-template", "files/template-knative.yaml").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "podtest-knative2"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - Eventually(IntegrationConditionStatus(ns, "podtest-knative2", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) + Eventually(IntegrationConditionStatus(ns, "podtest-knative2", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue)) Expect(KamelRunWithID(operatorID, ns, "files/podtest-knative1.groovy").Execute()).To(Succeed()) Eventually(IntegrationPodPhase(ns, "podtest-knative1"), TestTimeoutLong).Should(Equal(corev1.PodRunning)) - Eventually(IntegrationConditionStatus(ns, "podtest-knative1", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue)) + Eventually(IntegrationConditionStatus(ns, "podtest-knative1", v1.IntegrationConditionReady), TestTimeoutMedium).Should(Equal(corev1.ConditionTrue)) Eventually(IntegrationLogs(ns, "podtest-knative1"), TestTimeoutShort).Should(ContainSubstring("hello from the template")) Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed()) diff --git a/e2e/knative/support/startup_test.go b/e2e/knative/support/startup_test.go index da04425dbe..e105f76f3b 100644 --- a/e2e/knative/support/startup_test.go +++ b/e2e/knative/support/startup_test.go @@ -23,6 +23,9 @@ limitations under the License. package support import ( + "fmt" + "os/exec" + "path" "testing" . "github.com/onsi/gomega" @@ -48,4 +51,18 @@ func TestKNativeCamelKInstallStartup(t *testing.T) { Eventually(Platform(ns.GetName())).ShouldNot(BeNil()) Eventually(PlatformConditionStatus(ns.GetName(), v1.IntegrationPlatformConditionTypeCreated), TestTimeoutShort). Should(Equal(corev1.ConditionTrue)) + + // We must include namespace privileges to manage Knative objects + testDir := "../../../" + kustomizeCmd := exec.Command("kustomize", "edit", "set", "namespace", ns.GetName()) + kustomizeCmd.Dir = path.Join(testDir, "config/rbac/namespaced/knative") + ExpectExecSucceed(t, kustomizeCmd) + replaceORBKCmd := exec.Command( + "sed", "-i", fmt.Sprintf("s/namespace: .*/namespace: %s/", ns.GetName()), "operator-role-binding-knative.yaml", + ) + replaceORBKCmd.Dir = path.Join(testDir, "config/rbac/namespaced/knative") + ExpectExecSucceed(t, replaceORBKCmd) + kubectlApplyCmd := exec.Command("kubectl", "apply", "-k", ".") + kubectlApplyCmd.Dir = path.Join(testDir, "config/rbac/namespaced/knative") + ExpectExecSucceed(t, kubectlApplyCmd) } diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go index 371e8491ae..c66973fecc 100644 --- a/e2e/support/test_support.go +++ b/e2e/support/test_support.go @@ -103,10 +103,10 @@ const ciPID = "/tmp/ci-k8s-pid" const ExpectedCRDs = 8 // camel-k-operator, camel-k-operator-events, -// camel-k-operator-knative, camel-k-operator-leases, +// camel-k-operator-leases, // camel-k-operator-podmonitors, camel-k-operator-strimzi, // camel-k-operator-keda -const ExpectedKubePromoteRoles = 7 +const ExpectedKubePromoteRoles = 6 // camel-k-edit // camel-k-operator-custom-resource-definitions diff --git a/e2e/yaks/common/kamelet-beans/kamelet.feature b/e2e/yaks/common/kamelet-beans/kamelet-beans.feature similarity index 100% rename from e2e/yaks/common/kamelet-beans/kamelet.feature rename to e2e/yaks/common/kamelet-beans/kamelet-beans.feature diff --git a/e2e/yaks/common/kamelet-binding-broker/kamelet-binding-broker.feature b/e2e/yaks/common/kamelet-binding-broker/kamelet-binding-broker.feature new file mode 100644 index 0000000000..2282bb61df --- /dev/null +++ b/e2e/yaks/common/kamelet-binding-broker/kamelet-binding-broker.feature @@ -0,0 +1,14 @@ +Feature: Camel K can bind Kamelets to the broker + + Background: + Given Camel K resource polling configuration + | maxAttempts | 40 | + | delayBetweenAttempts | 3000 | + + Scenario: Sending event to the custom broker with KameletBinding + Given Camel K integration logger-sink-binding-br is running + Then Camel K integration logger-sink-binding-br should print message: Hello Custom Event from sample-broker + + Scenario: Remove resources + Given delete Camel K integration timer-source-binding-br + Given delete Camel K integration logger-sink-binding-br diff --git a/e2e/yaks/common/kamelet-binding-broker/kamelet.feature b/e2e/yaks/common/kamelet-binding-broker/kamelet.feature deleted file mode 100644 index 3b8be0e198..0000000000 --- a/e2e/yaks/common/kamelet-binding-broker/kamelet.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Camel K can bind Kamelets to the broker - - Background: - Given Camel K resource polling configuration - | maxAttempts | 40 | - | delayBetweenAttempts | 3000 | - - Scenario: Sending event to the custom broker with KameletBinding - Given Camel K integration logger-sink-binding is running - Then Camel K integration logger-sink-binding should print message: Hello Custom Event from sample-broker - - Scenario: Remove resources - Given delete Camel K integration timer-source-binding - Given delete Camel K integration logger-sink-binding diff --git a/e2e/yaks/common/kamelet-binding-broker/logger-sink-binding.yaml b/e2e/yaks/common/kamelet-binding-broker/logger-sink-binding-br.yaml similarity index 97% rename from e2e/yaks/common/kamelet-binding-broker/logger-sink-binding.yaml rename to e2e/yaks/common/kamelet-binding-broker/logger-sink-binding-br.yaml index 523f21e586..0638a074c6 100644 --- a/e2e/yaks/common/kamelet-binding-broker/logger-sink-binding.yaml +++ b/e2e/yaks/common/kamelet-binding-broker/logger-sink-binding-br.yaml @@ -18,7 +18,7 @@ apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: - name: logger-sink-binding + name: logger-sink-binding-br spec: source: ref: diff --git a/e2e/yaks/common/kamelet-binding-broker/timer-source-binding.yaml b/e2e/yaks/common/kamelet-binding-broker/timer-source-binding-br.yaml similarity index 97% rename from e2e/yaks/common/kamelet-binding-broker/timer-source-binding.yaml rename to e2e/yaks/common/kamelet-binding-broker/timer-source-binding-br.yaml index 585be48205..0231d68f54 100644 --- a/e2e/yaks/common/kamelet-binding-broker/timer-source-binding.yaml +++ b/e2e/yaks/common/kamelet-binding-broker/timer-source-binding-br.yaml @@ -18,7 +18,7 @@ apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: - name: timer-source-binding + name: timer-source-binding-br spec: source: ref: diff --git a/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml b/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml index 3369a00764..5acd0956ce 100644 --- a/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml +++ b/e2e/yaks/common/kamelet-binding-broker/yaks-config.yaml @@ -19,16 +19,22 @@ config: namespace: temporary: true pre: +- name: knative configuration + run: | + cd ../../../../config/rbac/descoped/knative + sed -i "s/namespace: .*/namespace: default/" operator-cluster-role-binding-knative.yaml + kustomize edit set namespace default + kubectl apply -k . - name: installation run: | kubectl apply -f sample-broker.yaml -n $YAKS_NAMESPACE kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE kubectl apply -f logger-sink.kamelet.yaml -n $YAKS_NAMESPACE - kubectl apply -f timer-source-binding.yaml -n $YAKS_NAMESPACE - kubectl apply -f logger-sink-binding.yaml -n $YAKS_NAMESPACE - kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=15m -n $YAKS_NAMESPACE - kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=15m -n $YAKS_NAMESPACE + kubectl apply -f timer-source-binding-br.yaml -n $YAKS_NAMESPACE + kubectl apply -f logger-sink-binding-br.yaml -n $YAKS_NAMESPACE + kubectl wait kameletbinding timer-source-binding-br --for=condition=Ready --timeout=15m -n $YAKS_NAMESPACE + kubectl wait kameletbinding logger-sink-binding-br --for=condition=Ready --timeout=15m -n $YAKS_NAMESPACE post: - name: print dump if: env:CI=true && failure() diff --git a/e2e/yaks/common/kamelet-binding-http/kamelet.feature b/e2e/yaks/common/kamelet-binding-http/kamelet-binding-http.feature similarity index 100% rename from e2e/yaks/common/kamelet-binding-http/kamelet.feature rename to e2e/yaks/common/kamelet-binding-http/kamelet-binding-http.feature diff --git a/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml b/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml index 1922bf7bbb..152d687020 100644 --- a/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml +++ b/e2e/yaks/common/kamelet-binding-http/yaks-config.yaml @@ -19,6 +19,12 @@ config: namespace: temporary: true pre: +- name: knative configuration + run: | + cd ../../../../config/rbac/descoped/knative + sed -i "s/namespace: .*/namespace: default/" operator-cluster-role-binding-knative.yaml + kustomize edit set namespace default + kubectl apply -k . - name: installation run: | kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE diff --git a/e2e/yaks/common/kamelet-binding/kamelet.feature b/e2e/yaks/common/kamelet-binding/kamelet-binding.feature similarity index 50% rename from e2e/yaks/common/kamelet-binding/kamelet.feature rename to e2e/yaks/common/kamelet-binding/kamelet-binding.feature index eb977d33a9..6e0cf8c916 100644 --- a/e2e/yaks/common/kamelet-binding/kamelet.feature +++ b/e2e/yaks/common/kamelet-binding/kamelet-binding.feature @@ -6,9 +6,10 @@ Feature: Camel K can bind Kamelets | delayBetweenAttempts | 3000 | Scenario: Running integration using a simple Kamelet with KameletBinding - Given Camel K integration logger-sink-binding is running - Then Camel K integration logger-sink-binding should print message: Hello Kamelets + Given Camel K integration logger-sink-binding-kb is running + Then Camel K integration logger-sink-binding-kb should print message: Hello Kamelets Scenario: Remove resources - Given delete Camel K integration timer-source-binding - Given delete Camel K integration logger-sink-binding + Given delete Camel K integration timer-source-binding-kb + Given delete Camel K integration logger-sink-binding-kb + diff --git a/e2e/yaks/common/kamelet-binding/logger-sink-binding.yaml b/e2e/yaks/common/kamelet-binding/logger-sink-binding-kb.yaml similarity index 97% rename from e2e/yaks/common/kamelet-binding/logger-sink-binding.yaml rename to e2e/yaks/common/kamelet-binding/logger-sink-binding-kb.yaml index 8b892b67b8..908a3dd510 100644 --- a/e2e/yaks/common/kamelet-binding/logger-sink-binding.yaml +++ b/e2e/yaks/common/kamelet-binding/logger-sink-binding-kb.yaml @@ -18,7 +18,7 @@ apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: - name: logger-sink-binding + name: logger-sink-binding-kb spec: source: ref: diff --git a/e2e/yaks/common/kamelet-binding/timer-source-binding.yaml b/e2e/yaks/common/kamelet-binding/timer-source-binding-kb.yaml similarity index 97% rename from e2e/yaks/common/kamelet-binding/timer-source-binding.yaml rename to e2e/yaks/common/kamelet-binding/timer-source-binding-kb.yaml index 7752e3347e..d8d3683ffd 100644 --- a/e2e/yaks/common/kamelet-binding/timer-source-binding.yaml +++ b/e2e/yaks/common/kamelet-binding/timer-source-binding-kb.yaml @@ -18,7 +18,7 @@ apiVersion: camel.apache.org/v1alpha1 kind: KameletBinding metadata: - name: timer-source-binding + name: timer-source-binding-kb spec: source: ref: diff --git a/e2e/yaks/common/kamelet-binding/yaks-config.yaml b/e2e/yaks/common/kamelet-binding/yaks-config.yaml index 2df50d0e75..5d9fe5402a 100644 --- a/e2e/yaks/common/kamelet-binding/yaks-config.yaml +++ b/e2e/yaks/common/kamelet-binding/yaks-config.yaml @@ -19,6 +19,12 @@ config: namespace: temporary: true pre: +- name: knative configuration + run: | + cd ../../../../config/rbac/descoped/knative + sed -i "s/namespace: .*/namespace: default/" operator-cluster-role-binding-knative.yaml + kustomize edit set namespace default + kubectl apply -k . - name: installation run: | kubectl apply -f messages-channel.yaml -n $YAKS_NAMESPACE @@ -26,10 +32,10 @@ pre: kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE kubectl apply -f logger-sink.kamelet.yaml -n $YAKS_NAMESPACE - kubectl apply -f timer-source-binding.yaml -n $YAKS_NAMESPACE - kubectl apply -f logger-sink-binding.yaml -n $YAKS_NAMESPACE - kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE - kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE + kubectl apply -f timer-source-binding-kb.yaml -n $YAKS_NAMESPACE + kubectl apply -f logger-sink-binding-kb.yaml -n $YAKS_NAMESPACE + kubectl wait kameletbinding timer-source-binding-kb --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE + kubectl wait kameletbinding logger-sink-binding-kb --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE post: - name: print dump if: env:CI=true && failure() diff --git a/e2e/yaks/common/knative-broker/yaks-config.yaml b/e2e/yaks/common/knative-broker/yaks-config.yaml index cd754db649..846508c827 100644 --- a/e2e/yaks/common/knative-broker/yaks-config.yaml +++ b/e2e/yaks/common/knative-broker/yaks-config.yaml @@ -18,6 +18,13 @@ config: namespace: temporary: true +pre: +- name: knative configuration + run: | + cd ../../../../config/rbac/descoped/knative + sed -i "s/namespace: .*/namespace: default/" operator-cluster-role-binding-knative.yaml + kustomize edit set namespace default + kubectl apply -k . post: - name: print dump if: env:CI=true && failure() diff --git a/e2e/yaks/common/knative-sinkbinding-http/sinkbinding.feature b/e2e/yaks/common/knative-sinkbinding-http/sinkbinding-http.feature similarity index 100% rename from e2e/yaks/common/knative-sinkbinding-http/sinkbinding.feature rename to e2e/yaks/common/knative-sinkbinding-http/sinkbinding-http.feature diff --git a/e2e/yaks/common/knative-sinkbinding-http/yaks-config.yaml b/e2e/yaks/common/knative-sinkbinding-http/yaks-config.yaml index e50bd2be4b..98452497cb 100644 --- a/e2e/yaks/common/knative-sinkbinding-http/yaks-config.yaml +++ b/e2e/yaks/common/knative-sinkbinding-http/yaks-config.yaml @@ -19,6 +19,12 @@ config: namespace: temporary: true pre: +- name: knative configuration + run: | + cd ../../../../config/rbac/descoped/knative + sed -i "s/namespace: .*/namespace: default/" operator-cluster-role-binding-knative.yaml + kustomize edit set namespace default + kubectl apply -k . - name: installation run: | kubectl -n knative-eventing set env deployments eventing-webhook --containers="eventing-webhook" SINK_BINDING_SELECTION_MODE=inclusion diff --git a/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml b/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml index a6cc095467..9fae21bd40 100644 --- a/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml +++ b/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml @@ -19,6 +19,12 @@ config: namespace: temporary: true pre: +- name: knative configuration + run: | + cd ../../../../config/rbac/descoped/knative + sed -i "s/namespace: .*/namespace: default/" operator-cluster-role-binding-knative.yaml + kustomize edit set namespace default + kubectl apply -k . - name: installation run: | kubectl apply -n $YAKS_NAMESPACE -f messages-channel.yaml diff --git a/helm/camel-k/README.md b/helm/camel-k/README.md index 838d78a8ea..1daa47960e 100644 --- a/helm/camel-k/README.md +++ b/helm/camel-k/README.md @@ -1,15 +1,13 @@ # Camel K -Apache Camel K is a lightweight integration platform, born on Kubernetes, -with serverless superpowers. +Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers: the easiest way to build and manage your Camel applications on Kubernetes. -This chart deploys the Camel K operator and all resources needed to natively run -Apache Camel integrations on any Kubernetes cluster. +This chart deploys the Camel K operator and all resources needed to natively run Apache Camel integrations on any Kubernetes cluster. ## Prerequisites - Kubernetes 1.11+ -- Container Image Registry installed and configured for pull +- Container Image Registry installed and configured for pull (optional in Openshift or Minikube) ## Installing the Chart @@ -19,22 +17,33 @@ To install the chart, first add the Camel K repository: $ helm repo add camel-k https://apache.github.io/camel-k/charts ``` -If you are installing on OpenShift, Camel K can use the OpenShift internal registry to -store and pull images. +Depending on the cloud platform of choice, you will need to specify a container registry at installation time. -Installation on OpenShift can be done with command: +### Plain Kubernetes + +A regular installation requires you to provide a registry, used by Camel K to build application containers. See official [Camel K registry documentation](https://camel.apache.org/camel-k/next/installation/registry/registry.html). + +```bash +$ helm install camel-k \ + --set platform.build.registry.address= \ + camel-k/camel-k +``` + +You may install Camel K and specify a container registry later. + +### Openshift + +If you are installing on OpenShift, Camel K can use the OpenShift internal registry to store and pull images: ```bash -$ helm install \ - --generate-name \ +$ helm install camel-k \ --set platform.cluster=OpenShift \ camel-k/camel-k ``` -When running on a cluster with no embedded internal registry, you need to specify the address -and properties of an image registry that the cluster can use to store image. +### Minikube -For example, on Minikube you can enable the internal registry and get its address: +Minikube offers a container registry addon, which it makes very well suited for local Camel K development and testing purposes. You can export the cluster IP registry addon using the following script: ```bash $ minikube addons enable registry @@ -44,15 +53,21 @@ $ export REGISTRY_ADDRESS=$(kubectl -n kube-system get service registry -o jsonp Then you can install Camel K with: ```bash -$ helm install \ - --generate-name \ +$ helm install camel-k \ --set platform.build.registry.address=${REGISTRY_ADDRESS} \ --set platform.build.registry.insecure=true \ camel-k/camel-k ``` -The [configuration](#configuration) section lists -additional parameters that can be set during installation. +### Knative configuration + +Camel K offers the possibility to run serverless Integrations in conjunction with [Knative operator](https://knative.dev). Once Knative and Camel K are installed on the same platform, you can configure Knative resources to be played by Camel K. + +See instructions [how to enable Knative on Camel K](https://camel.apache.org/camel-k/next/installation/knative.html). + +### Additional installation time configuration + +The [configuration](#configuration) section lists additional parameters that can be set during installation. > **Tip**: List all releases using `helm list` @@ -91,8 +106,7 @@ $ kubectl delete -f camel-k/crds ## Configuration -The following table lists the most commonly configured parameters of the -Camel K chart and their default values. The chart allows configuration of an `IntegrationPlatform` resource, which among others includes build properties and traits configuration. A full list of parameters can be found [in the operator specification][1]. +The following table lists the most commonly configured parameters of the Camel K chart and their default values. The chart allows configuration of an `IntegrationPlatform` resource, which among others includes build properties and traits configuration. A full list of parameters can be found [in the operator specification][1]. | Parameter | Description | Default | |----------------------------------------|---------------------------------------------------------------------------|--------------------------------| @@ -111,9 +125,8 @@ Camel K chart and their default values. The chart allows configuration of an `In We'd like to hear your feedback and we love any kind of contribution! -The main contact points for the Camel K project are the [GitHub repository][2] -and the [Chat room][3]. +The main contact points for the Camel K project are the [GitHub repository][2] and the [Camel K chat room][3]. -[1]: https://camel.apache.org/camel-k/latest/architecture/cr/integration-platform.html +[1]: https://camel.apache.org/camel-k/next/architecture/cr/integration-platform.html [2]: https://github.com/apache/camel-k [3]: https://camel.zulipchat.com diff --git a/pkg/install/operator.go b/pkg/install/operator.go index b24dbe2f30..82931b5f35 100644 --- a/pkg/install/operator.go +++ b/pkg/install/operator.go @@ -41,7 +41,6 @@ import ( "github.com/apache/camel-k/v2/pkg/client" "github.com/apache/camel-k/v2/pkg/resources" "github.com/apache/camel-k/v2/pkg/util/envvar" - "github.com/apache/camel-k/v2/pkg/util/knative" "github.com/apache/camel-k/v2/pkg/util/kubernetes" "github.com/apache/camel-k/v2/pkg/util/minikube" "github.com/apache/camel-k/v2/pkg/util/openshift" @@ -272,24 +271,6 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client, return err } - // Additionally, install Knative resources (roles and bindings) - isKnative, err := knative.IsInstalled(c) - if err != nil { - return err - } - if isKnative { - if err := installKnative(ctx, c, cfg.Namespace, customizer, collection, force, cfg.Global); err != nil { - return err - } - if err := installClusterRoleBinding(ctx, c, collection, cfg.Namespace, "camel-k-operator-bind-addressable-resolver", "/rbac/operator-cluster-role-binding-addressable-resolver.yaml"); err != nil { - if k8serrors.IsForbidden(err) { - fmt.Fprintln(cmd.ErrOrStderr(), "Warning: the operator will not be able to bind Knative addressable-resolver ClusterRole. Try installing the operator as cluster-admin.") - } else { - return err - } - } - } - if err = installEvents(ctx, c, cfg.Namespace, customizer, collection, force, cfg.Global); err != nil { if k8serrors.IsAlreadyExists(err) { return err @@ -523,20 +504,6 @@ func installKedaBindings(ctx context.Context, c client.Client, namespace string, } } -func installKnative(ctx context.Context, c client.Client, namespace string, customizer ResourceCustomizer, collection *kubernetes.Collection, force bool, global bool) error { - if global { - return ResourcesOrCollect(ctx, c, namespace, collection, force, customizer, - "/rbac/descoped/operator-cluster-role-knative.yaml", - "/rbac/descoped/operator-cluster-role-binding-knative.yaml", - ) - } else { - return ResourcesOrCollect(ctx, c, namespace, collection, force, customizer, - "/rbac/namespaced/operator-role-knative.yaml", - "/rbac/namespaced/operator-role-binding-knative.yaml", - ) - } -} - func installEvents(ctx context.Context, c client.Client, namespace string, customizer ResourceCustomizer, collection *kubernetes.Collection, force bool, global bool) error { if global { return ResourcesOrCollect(ctx, c, namespace, collection, force, customizer,