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 2022/02/07 18:46:35 UTC
[camel-k] branch release-1.8.x updated (7a67ba0 -> 18c7786)
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a change to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git.
from 7a67ba0 fix(cli): kamel run -v should configure the mount trait
new 53a5b76 fix(rbac): Add kafkachannels to default Knative Sinks RBAC
new 60b8e61 chore(doc): Document RBAC requirements for Knative Sinks
new b151e20 feat(knative): Bind the Addressable resolver aggregated ClusterRole to the operator SA
new b6c811a chore(rbac): Remove hard-coded permissions for Knative Addressable
new 9f8fe41 chore(doc): Document Knative Addressable resolver RBAC for Knative Sinks
new 0f493fb chore(rbac): Add bind permission on the addressable-resolver ClusterRole
new 35f82b2 chore(knative): Bind the addressable-resolver ClusterRole according to deployment mode
new ded50a6 chore(cli): Install Knative addressable-resolver ClusterRole and ClusterRoleBinding
new 18c7786 fix(e2e): Account for addressable-resolver ClusterRole
The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
config/rbac/kustomization.yaml | 3 +-
...perator-cluster-role-addressable-resolver.yaml} | 10 ++-
...cluster-role-binding-addressable-resolver.yaml} | 4 +-
config/rbac/operator-role-knative.yaml | 15 ----
docs/modules/ROOT/nav.adoc | 1 +
.../ROOT/pages/installation/advanced/knative.adoc | 48 ++++++++++++
e2e/common/kustomize/common.go | 6 +-
helm/camel-k/templates/operator-role.yaml | 13 ----
pkg/install/cluster.go | 18 +++++
pkg/install/common.go | 2 +
pkg/install/knative.go | 85 ++++++++++++++++++++++
pkg/install/operator.go | 50 +++++++------
pkg/install/optional.go | 8 +-
pkg/resources/resources.go | 20 ++++-
14 files changed, 221 insertions(+), 62 deletions(-)
copy config/rbac/{operator-cluster-role-custom-resource-definitions.yaml => operator-cluster-role-addressable-resolver.yaml} (87%)
copy config/rbac/{openshift/operator-cluster-role-console-binding-openshift.yaml => operator-cluster-role-binding-addressable-resolver.yaml} (92%)
create mode 100644 docs/modules/ROOT/pages/installation/advanced/knative.adoc
create mode 100644 pkg/install/knative.go
[camel-k] 09/09: fix(e2e): Account for addressable-resolver ClusterRole
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 18c7786b89a1e37b4fc907f3da3010b962a50360
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Mon Jan 31 10:54:55 2022 +0100
fix(e2e): Account for addressable-resolver ClusterRole
---
e2e/common/kustomize/common.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/e2e/common/kustomize/common.go b/e2e/common/kustomize/common.go
index adbb2ff..fee820c 100644
--- a/e2e/common/kustomize/common.go
+++ b/e2e/common/kustomize/common.go
@@ -1,3 +1,4 @@
+//go:build integration
// +build integration
// To enable compilation of this file in Goland, go to "Settings -> Go -> Vendoring & Build Tags -> Custom Tags" and add "integration"
@@ -46,7 +47,8 @@ const (
// camel-k-edit
// camel-k-operator-custom-resource-definitions
- ExpKubeClusterRoles = 2
+ // camel-k-operator-bind-addressable-resolver
+ ExpKubeClusterRoles = 3
// camel-k-operator-openshift
ExpOSPromoteRoles = 1
@@ -75,8 +77,6 @@ func ExecMake(t *testing.T, command *exec.Cmd) {
}
func Uninstall() {
- //
// Removes all items including CRDs and ClusterRoles
- //
Kamel("uninstall", "--olm=false", "--all").Execute()
}
[camel-k] 01/09: fix(rbac): Add kafkachannels to default Knative Sinks RBAC
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 53a5b7699c1d11dfa6e6b5e3c975a82632cf4a11
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Thu Jan 27 15:40:45 2022 +0100
fix(rbac): Add kafkachannels to default Knative Sinks RBAC
---
config/rbac/operator-role-knative.yaml | 1 +
pkg/resources/resources.go | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/config/rbac/operator-role-knative.yaml b/config/rbac/operator-role-knative.yaml
index 12bdd50..296bdf2 100644
--- a/config/rbac/operator-role-knative.yaml
+++ b/config/rbac/operator-role-knative.yaml
@@ -80,5 +80,6 @@ rules:
resources:
- channels
- inmemorychannels
+ - kafkachannels
verbs:
- get
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index e7785bf..1f492d8 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -357,9 +357,9 @@ var assets = func() http.FileSystem {
"/rbac/operator-role-knative.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-role-knative.yaml",
modTime: time.Time{},
- uncompressedSize: 1899,
+ uncompressedSize: 1917,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x54\xc1\x8e\xdb\x36\x10\xbd\xf3\x2b\x1e\xac\x4b\x02\xac\xe5\xb6\xa7\xc2\x3d\xb9\x9b\xdd\xd6\x68\x60\x03\x96\xd3\x45\x8e\x94\x34\x96\x06\xa6\x48\x75\x48\x59\xeb\x7e\x7d\x41\x5a\x6e\x9c\x6e\x81\x2d\x8a\x8d\x2e\x1e\xd1\x4f\x33\xef\xcd\x1b\x4e\x86\xf9\xdb\x3d\x2a\xc3\x47\xae\xc8\x7a\xaa\x11\x1c\x42\x4b\x58\xf5\xba\x6a\x09\x85\x3b\x84\x51\x0b\xe1\xd1\x0d\xb6\xd6\x81\x9d\xc5\xbb\x55\xf1\xf8\x1e\x83\xad\x49\xe0\x2c\xc1\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x54\x41\x6f\xe3\x46\x0f\xbd\xeb\x57\x3c\x58\x97\x5d\x20\x56\xbe\xaf\xa7\xc2\x3d\xb9\xd9\xa4\x35\xba\xb0\x81\xc8\xdb\x60\x8f\x94\x44\x4b\x84\x46\x33\x2a\x67\x64\x25\xfd\xf5\xc5\x4c\xec\xae\xd3\x14\x48\x51\xa4\xba\x98\xa2\x9f\xc8\xf7\xe6\x71\x98\x63\xf9\x7e\x4f\x96\xe3\xb3\xd4\x6c\x3d\x37\x08\x0e\xa1\x63\xac\x47\xaa\x3b\x46\xe9\x0e\x61\x26\x65\xdc\xb9\xc9\x36\x14\xc4\x59\x7c\x58\x97\x77\x1f\x31\xd9\x86\x15\xce\x32\x [...]
},
"/rbac/operator-role-leases.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-role-leases.yaml",
[camel-k] 07/09: chore(knative): Bind the addressable-resolver ClusterRole according to deployment mode
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 35f82b2a98cd923c08fd65e2580715f4da74ceb2
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Jan 28 17:30:43 2022 +0100
chore(knative): Bind the addressable-resolver ClusterRole according to deployment mode
---
pkg/install/knative.go | 29 +++++++++++++++++++++++++++--
pkg/install/operator.go | 4 ++--
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/pkg/install/knative.go b/pkg/install/knative.go
index db77b87..6f30db5 100644
--- a/pkg/install/knative.go
+++ b/pkg/install/knative.go
@@ -25,8 +25,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1"
+ "k8s.io/client-go/kubernetes"
- "github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/util/knative"
)
@@ -34,13 +34,38 @@ const knativeAddressableResolverClusterRoleName = "addressable-resolver"
// BindKnativeAddressableResolverClusterRole binds the Knative Addressable resolver aggregated ClusterRole
// to the operator ServiceAccount.
-func BindKnativeAddressableResolverClusterRole(ctx context.Context, c client.Client, namespace string) error {
+func BindKnativeAddressableResolverClusterRole(ctx context.Context, c kubernetes.Interface, namespace string) error {
if isKnative, err := knative.IsInstalled(ctx, c); err != nil {
return err
} else if !isKnative {
return nil
}
+ if namespace != "" {
+ return applyAddressableResolverRoleBinding(ctx, c, namespace)
+ }
+ return applyAddressableResolverClusterRoleBinding(ctx, c, namespace)
+}
+
+func applyAddressableResolverRoleBinding(ctx context.Context, c kubernetes.Interface, namespace string) error {
+ rb := rbacv1ac.RoleBinding(fmt.Sprintf("%s-addressable-resolver", serviceAccountName), namespace).
+ WithSubjects(
+ rbacv1ac.Subject().
+ WithKind("ServiceAccount").
+ WithNamespace(namespace).
+ WithName(serviceAccountName),
+ ).
+ WithRoleRef(rbacv1ac.RoleRef().
+ WithAPIGroup(rbacv1.GroupName).
+ WithKind("ClusterRole").
+ WithName(knativeAddressableResolverClusterRoleName))
+
+ _, err := c.RbacV1().RoleBindings(namespace).
+ Apply(ctx, rb, metav1.ApplyOptions{FieldManager: serviceAccountName, Force: true})
+
+ return err
+}
+func applyAddressableResolverClusterRoleBinding(ctx context.Context, c kubernetes.Interface, namespace string) error {
crb := rbacv1ac.ClusterRoleBinding(fmt.Sprintf("%s-addressable-resolver", serviceAccountName)).
WithSubjects(
rbacv1ac.Subject().
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index d602bb5..47c5a0c 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -334,7 +334,7 @@ func installClusterRoleBinding(ctx context.Context, c client.Client, collection
bound := false
for i, subject := range target.Subjects {
- if subject.Name == "camel-k-operator" {
+ if subject.Name == serviceAccountName {
if subject.Namespace == namespace {
bound = true
@@ -352,7 +352,7 @@ func installClusterRoleBinding(ctx context.Context, c client.Client, collection
target.Subjects = append(target.Subjects, rbacv1.Subject{
Kind: "ServiceAccount",
Namespace: namespace,
- Name: "camel-k-operator",
+ Name: serviceAccountName,
})
}
[camel-k] 04/09: chore(rbac): Remove hard-coded permissions for Knative Addressable
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b6c811a29ccfc977c7b468f3f1a5c38d8815f955
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Jan 28 12:19:42 2022 +0100
chore(rbac): Remove hard-coded permissions for Knative Addressable
---
config/rbac/operator-role-knative.yaml | 16 ----------------
helm/camel-k/templates/operator-role.yaml | 13 -------------
pkg/resources/resources.go | 4 ++--
3 files changed, 2 insertions(+), 31 deletions(-)
diff --git a/config/rbac/operator-role-knative.yaml b/config/rbac/operator-role-knative.yaml
index 296bdf2..8b37180 100644
--- a/config/rbac/operator-role-knative.yaml
+++ b/config/rbac/operator-role-knative.yaml
@@ -67,19 +67,3 @@ rules:
- list
- patch
- update
- # Required to resolve Addressable Sinks
- # We may want to external it and make it extensible
-- apiGroups:
- - eventing.knative.dev
- resources:
- - brokers
- verbs:
- - get
-- apiGroups:
- - messaging.knative.dev
- resources:
- - channels
- - inmemorychannels
- - kafkachannels
- verbs:
- - get
diff --git a/helm/camel-k/templates/operator-role.yaml b/helm/camel-k/templates/operator-role.yaml
index d30c8eb..81f23b8 100644
--- a/helm/camel-k/templates/operator-role.yaml
+++ b/helm/camel-k/templates/operator-role.yaml
@@ -236,19 +236,6 @@ rules:
- patch
- update
- apiGroups:
- - eventing.knative.dev
- resources:
- - brokers
- verbs:
- - get
-- apiGroups:
- - messaging.knative.dev
- resources:
- - channels
- - inmemorychannels
- verbs:
- - get
-- apiGroups:
- coordination.k8s.io
resources:
- leases
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 1f492d8..55bf8de 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -357,9 +357,9 @@ var assets = func() http.FileSystem {
"/rbac/operator-role-knative.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-role-knative.yaml",
modTime: time.Time{},
- uncompressedSize: 1917,
+ uncompressedSize: 1620,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x54\x41\x6f\xe3\x46\x0f\xbd\xeb\x57\x3c\x58\x97\x5d\x20\x56\xbe\xaf\xa7\xc2\x3d\xb9\xd9\xa4\x35\xba\xb0\x81\xc8\xdb\x60\x8f\x94\x44\x4b\x84\x46\x33\x2a\x67\x64\x25\xfd\xf5\xc5\x4c\xec\xae\xd3\x14\x48\x51\xa4\xba\x98\xa2\x9f\xc8\xf7\xe6\x71\x98\x63\xf9\x7e\x4f\x96\xe3\xb3\xd4\x6c\x3d\x37\x08\x0e\xa1\x63\xac\x47\xaa\x3b\x46\xe9\x0e\x61\x26\x65\xdc\xb9\xc9\x36\x14\xc4\x59\x7c\x58\x97\x77\x1f\x31\xd9\x86\x15\xce\x32\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x94\x41\x6f\xdb\x46\x10\x85\xef\xfb\x2b\x1e\xc4\x4b\x02\x58\x74\xdb\x53\xa1\x9e\x54\xc7\x6e\x89\x06\x12\x60\x2a\x0d\x72\x1c\x92\x23\x72\x20\x72\x77\x3b\xbb\x14\xe3\xfe\xfa\x82\x2b\xaa\x71\xe0\x83\x2f\x0e\x2f\x1a\xad\x66\x67\xbe\x37\x6f\xc4\x0c\xeb\xb7\x7b\x4c\x86\x8f\x52\xb3\x0d\xdc\x20\x3a\xc4\x8e\xb1\xf5\x54\x77\x8c\xd2\x1d\xe3\x44\xca\x78\x70\xa3\x6d\x28\x8a\xb3\x78\xb7\x2d\x1f\xde\x63\xb4\x0d\x2b\x9c\x65\x38\x [...]
},
"/rbac/operator-role-leases.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-role-leases.yaml",
[camel-k] 05/09: chore(doc): Document Knative Addressable resolver RBAC for Knative Sinks
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 9f8fe41f7864018e342205ff06d7bced2da46c5f
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Jan 28 12:31:39 2022 +0100
chore(doc): Document Knative Addressable resolver RBAC for Knative Sinks
---
.../ROOT/pages/installation/advanced/knative.adoc | 43 ++--------------------
1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/docs/modules/ROOT/pages/installation/advanced/knative.adoc b/docs/modules/ROOT/pages/installation/advanced/knative.adoc
index 7bb61d7..a67d6ca 100644
--- a/docs/modules/ROOT/pages/installation/advanced/knative.adoc
+++ b/docs/modules/ROOT/pages/installation/advanced/knative.adoc
@@ -41,45 +41,8 @@ However, a Knative Sink can be any Kubernetes resource that's _addressable_, i.e
This is what the Camel K operator does to resolve the Sink URLs, so that events can be sent to.
That requires the ServiceAccount that runs the operator to be granted permission to GET these resources, while it configures the integration runtime.
-As the set of resources is arbitrary, and cannot be known _a-priori_, these permissions must be added to a Camel K operator Role, or ClusterRole, that's bound to the `camel-k-operator` ServiceAccount.
+As the set of resources is arbitrary, and cannot be known _a-priori_, these permissions are automatically granted to `camel-k-operator` ServiceAccount, by relying on the Knative Addressable resolver aggregated ClusterRole.
-For the above examples, that sink into an `eventing.knative.dev/broker` resource, this can be achieved by creating the following resources:
+For the above examples, that sink into an `eventing.knative.dev/broker` resource, this is already being configured by Knative, that aggregates the required permissions for its own resources by default.
-.operator-role-knative-sinks.yaml
-[source,yaml]
-----
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app: camel-k
- name: camel-k-operator-knative-sinks
-rules:
-- apiGroups:
- - eventing.knative.dev
- resources:
- - brokers
- verbs:
- - get
-----
-
-.operator-rolebinding-knative-sinks.yaml
-[source,yaml]
-----
-kind: ClusterRoleBinding
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
- name: camel-k-operator-knative-sinks
- labels:
- app: "camel-k"
-subjects:
-- kind: ServiceAccount
- name: camel-k-operator
- namespace: camel-k
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: camel-k-operator-knative-sinks
-----
-
-These resources apply when the Camel K operator is deployed in _global_ mode, into the `camel-k` namespace, and should be adapted depending on how the operator is actually deployed.
+However, if you integrate custom resources as sinks, the required permissions must be added manually, as documented in the https://knative.dev/docs/eventing/sinks/#using-custom-resources-as-sinks[Knative documentation].
[camel-k] 03/09: feat(knative): Bind the Addressable resolver aggregated ClusterRole to the operator SA
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b151e2086750fc6f7102aaaa994bd72caf7ec6f9
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Jan 28 12:17:36 2022 +0100
feat(knative): Bind the Addressable resolver aggregated ClusterRole to the operator SA
---
pkg/install/common.go | 2 ++
pkg/install/knative.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
pkg/install/optional.go | 8 ++++++-
3 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/pkg/install/common.go b/pkg/install/common.go
index e131298..a8606ed 100644
--- a/pkg/install/common.go
+++ b/pkg/install/common.go
@@ -35,6 +35,8 @@ import (
"github.com/apache/camel-k/pkg/util/openshift"
)
+const serviceAccountName = "camel-k-operator"
+
// ResourceCustomizer can be used to inject code that changes the objects before they are created.
type ResourceCustomizer func(object ctrl.Object) ctrl.Object
diff --git a/pkg/install/knative.go b/pkg/install/knative.go
new file mode 100644
index 0000000..db77b87
--- /dev/null
+++ b/pkg/install/knative.go
@@ -0,0 +1,60 @@
+/*
+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 install
+
+import (
+ "context"
+ "fmt"
+
+ rbacv1 "k8s.io/api/rbac/v1"
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
+ rbacv1ac "k8s.io/client-go/applyconfigurations/rbac/v1"
+
+ "github.com/apache/camel-k/pkg/client"
+ "github.com/apache/camel-k/pkg/util/knative"
+)
+
+const knativeAddressableResolverClusterRoleName = "addressable-resolver"
+
+// BindKnativeAddressableResolverClusterRole binds the Knative Addressable resolver aggregated ClusterRole
+// to the operator ServiceAccount.
+func BindKnativeAddressableResolverClusterRole(ctx context.Context, c client.Client, namespace string) error {
+ if isKnative, err := knative.IsInstalled(ctx, c); err != nil {
+ return err
+ } else if !isKnative {
+ return nil
+ }
+
+ crb := rbacv1ac.ClusterRoleBinding(fmt.Sprintf("%s-addressable-resolver", serviceAccountName)).
+ WithSubjects(
+ rbacv1ac.Subject().
+ WithKind("ServiceAccount").
+ WithNamespace(namespace).
+ WithName(serviceAccountName),
+ ).
+ WithRoleRef(rbacv1ac.RoleRef().
+ WithAPIGroup(rbacv1.GroupName).
+ WithKind("ClusterRole").
+ WithName(knativeAddressableResolverClusterRoleName))
+
+ _, err := c.RbacV1().ClusterRoleBindings().
+ Apply(ctx, crb, metav1.ApplyOptions{FieldManager: serviceAccountName, Force: true})
+
+ return err
+}
diff --git a/pkg/install/optional.go b/pkg/install/optional.go
index 10da131..dd3d0fc 100644
--- a/pkg/install/optional.go
+++ b/pkg/install/optional.go
@@ -21,10 +21,10 @@ import (
"context"
"strings"
- "github.com/apache/camel-k/pkg/util/defaults"
"github.com/go-logr/logr"
"github.com/apache/camel-k/pkg/client"
+ "github.com/apache/camel-k/pkg/util/defaults"
)
// OperatorStartupOptionalTools tries to install optional tools at operator startup and warns if something goes wrong.
@@ -63,4 +63,10 @@ func OperatorStartupOptionalTools(ctx context.Context, c client.Client, namespac
}
}
}
+
+ // Try to bind the Knative Addressable resolver aggregated ClusterRole to the operator ServiceAccount
+ if err := BindKnativeAddressableResolverClusterRole(ctx, c, namespace); err != nil {
+ log.Info("Cannot bind the Knative Addressable resolver aggregated ClusterRole: skipping.")
+ log.V(8).Info("Error while binding the Knative Addressable resolver aggregated ClusterRole", "error", err)
+ }
}
[camel-k] 06/09: chore(rbac): Add bind permission on the addressable-resolver ClusterRole
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0f493fb8d3102bd5ce3ff057918df509bc898dc1
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Jan 28 17:28:00 2022 +0100
chore(rbac): Add bind permission on the addressable-resolver ClusterRole
---
config/rbac/kustomization.yaml | 3 +-
...perator-cluster-role-addressable-resolver.yaml} | 40 ++++++++--------------
...cluster-role-binding-addressable-resolver.yaml} | 39 ++++++++-------------
pkg/resources/resources.go | 16 +++++++++
4 files changed, 47 insertions(+), 51 deletions(-)
diff --git a/config/rbac/kustomization.yaml b/config/rbac/kustomization.yaml
index 7f03ac1..6e488ca 100644
--- a/config/rbac/kustomization.yaml
+++ b/config/rbac/kustomization.yaml
@@ -39,4 +39,5 @@ resources:
- operator-role-binding.yaml
- operator-cluster-role-custom-resource-definitions.yaml
- operator-cluster-role-binding-custom-resource-definitions.yaml
-
+- operator-cluster-role-addressable-resolver.yaml
+- operator-cluster-role-binding-addressable-resolver.yaml
diff --git a/config/rbac/kustomization.yaml b/config/rbac/operator-cluster-role-addressable-resolver.yaml
similarity index 56%
copy from config/rbac/kustomization.yaml
copy to config/rbac/operator-cluster-role-addressable-resolver.yaml
index 7f03ac1..9428404 100644
--- a/config/rbac/kustomization.yaml
+++ b/config/rbac/operator-cluster-role-addressable-resolver.yaml
@@ -15,28 +15,18 @@
# limitations under the License.
# ---------------------------------------------------------------------------
-#
-# rbac resources applicable for all kubernetes platforms
-#
-apiVersion: kustomize.config.k8s.io/v1beta1
-kind: Kustomization
-
-resources:
-- user-cluster-role.yaml
-- operator-role-events.yaml
-- operator-role-knative.yaml
-- operator-role.yaml
-- operator-role-keda.yaml
-- operator-role-leases.yaml
-- operator-role-podmonitors.yaml
-- 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
-- operator-role-binding.yaml
-- operator-cluster-role-custom-resource-definitions.yaml
-- operator-cluster-role-binding-custom-resource-definitions.yaml
-
+kind: ClusterRole
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+ name: camel-k-operator-bind-addressable-resolver
+ labels:
+ app: "camel-k"
+rules:
+- apiGroups:
+ - rbac.authorization.k8s.io
+ resources:
+ - clusterroles
+ resourceNames:
+ - addressable-resolver
+ verbs:
+ - bind
diff --git a/config/rbac/kustomization.yaml b/config/rbac/operator-cluster-role-binding-addressable-resolver.yaml
similarity index 56%
copy from config/rbac/kustomization.yaml
copy to config/rbac/operator-cluster-role-binding-addressable-resolver.yaml
index 7f03ac1..bddbcfd 100644
--- a/config/rbac/kustomization.yaml
+++ b/config/rbac/operator-cluster-role-binding-addressable-resolver.yaml
@@ -15,28 +15,17 @@
# limitations under the License.
# ---------------------------------------------------------------------------
-#
-# rbac resources applicable for all kubernetes platforms
-#
-apiVersion: kustomize.config.k8s.io/v1beta1
-kind: Kustomization
-
-resources:
-- user-cluster-role.yaml
-- operator-role-events.yaml
-- operator-role-knative.yaml
-- operator-role.yaml
-- operator-role-keda.yaml
-- operator-role-leases.yaml
-- operator-role-podmonitors.yaml
-- 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
-- operator-role-binding.yaml
-- operator-cluster-role-custom-resource-definitions.yaml
-- operator-cluster-role-binding-custom-resource-definitions.yaml
-
+kind: ClusterRoleBinding
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+ name: camel-k-operator-bind-addressable-resolver
+ labels:
+ app: "camel-k"
+subjects:
+- kind: ServiceAccount
+ name: camel-k-operator
+ namespace: placeholder
+roleRef:
+ kind: ClusterRole
+ name: camel-k-operator-bind-addressable-resolver
+ apiGroup: rbac.authorization.k8s.io
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 55bf8de..dadad53 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -277,6 +277,20 @@ var assets = func() http.FileSystem {
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x53\xc1\x8e\xdb\x46\x0c\xbd\xeb\x2b\x08\xeb\x92\x00\x6b\xa9\xed\xa9\x70\x4f\xee\x66\xb7\x35\x1a\xd8\xc0\xca\x69\x90\x23\x35\xa2\x25\xc2\xa3\xa1\xca\x19\xad\xb2\xf9\xfa\x62\xc6\x76\xe2\xac\xe3\xcd\x25\x40\x74\x11\x4d\x3e\x93\xef\xf1\x51\x39\xcc\x7f\xdc\x93\xe5\xf0\x96\x0d\x39\x4f\x0d\x04\x81\xd0\x11\x2c\x07\x34\x1d\x41\x25\xbb\x30\xa1\x12\xdc\xcb\xe8\x1a\x0c\x2c\x0e\x5e\x2d\xab\xfb\xd7\x30\xba\x86\x14\xc4\x11\x88\x [...]
},
+ "/rbac/operator-cluster-role-addressable-resolver.yaml": &vfsgen۰CompressedFileInfo{
+ name: "operator-cluster-role-addressable-resolver.yaml",
+ modTime: time.Time{},
+ uncompressedSize: 1228,
+
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x93\x41\x8f\xdb\x36\x10\x85\xef\xfc\x15\x0f\xd6\x25\x01\x56\x72\xdb\x53\xe1\x9e\xdc\xcd\x6e\x2b\x34\xb0\x81\x95\xd3\x20\x47\x5a\x1c\x4b\x83\xa5\x38\xea\x90\x5a\x65\xfb\xeb\x0b\xca\x76\xe3\x20\xc8\x2d\xbc\x09\x7c\x9c\xf9\xde\xbc\x51\x81\xf2\xc7\x1d\x53\xe0\x3d\xb7\x14\x22\x39\x24\x41\xea\x09\xdb\xd1\xb6\x3d\xa1\x91\x53\x9a\xad\x12\x1e\x65\x0a\xce\x26\x96\x80\x37\xdb\xe6\xf1\x2d\xa6\xe0\x48\x21\x81\x20\x8a\x41\x94\x [...]
+ },
+ "/rbac/operator-cluster-role-binding-addressable-resolver.yaml": &vfsgen۰CompressedFileInfo{
+ name: "operator-cluster-role-binding-addressable-resolver.yaml",
+ modTime: time.Time{},
+ uncompressedSize: 1296,
+
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xcd\x8e\xdb\x36\x10\xbe\xf3\x29\x3e\x58\x97\x04\x58\xcb\x6d\x4f\x85\x7b\x72\x36\xbb\xad\xd0\xc0\x06\x2c\xa7\x41\x8e\x34\x35\x96\xa6\x4b\x71\xd4\x21\xb5\x8a\xfb\xf4\x05\x65\xbb\xd9\x20\x68\x0f\x41\x78\x13\xc8\x99\xef\x57\x05\x96\xdf\xef\x98\x02\xef\xd8\x51\x88\xd4\x20\x09\x52\x47\xd8\x0c\xd6\x75\x84\x5a\x4e\x69\xb2\x4a\x78\x94\x31\x34\x36\xb1\x04\xbc\xda\xd4\x8f\xaf\x31\x86\x86\x14\x12\x08\xa2\xe8\x45\xc9\x14\x [...]
+ },
"/rbac/operator-cluster-role-binding-custom-resource-definitions.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-cluster-role-binding-custom-resource-definitions.yaml",
modTime: time.Time{},
@@ -624,6 +638,8 @@ var assets = func() http.FileSystem {
}
fs["/rbac"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
fs["/rbac/openshift"].(os.FileInfo),
+ fs["/rbac/operator-cluster-role-addressable-resolver.yaml"].(os.FileInfo),
+ fs["/rbac/operator-cluster-role-binding-addressable-resolver.yaml"].(os.FileInfo),
fs["/rbac/operator-cluster-role-binding-custom-resource-definitions.yaml"].(os.FileInfo),
fs["/rbac/operator-cluster-role-custom-resource-definitions.yaml"].(os.FileInfo),
fs["/rbac/operator-role-binding-events.yaml"].(os.FileInfo),
[camel-k] 08/09: chore(cli): Install Knative addressable-resolver ClusterRole and ClusterRoleBinding
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit ded50a674aa98fb8d436ac1fed0d170406e6b7d0
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Mon Jan 31 10:53:36 2022 +0100
chore(cli): Install Knative addressable-resolver ClusterRole and ClusterRoleBinding
---
pkg/install/cluster.go | 18 ++++++++++++++++++
pkg/install/operator.go | 46 +++++++++++++++++++++++++++-------------------
2 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/pkg/install/cluster.go b/pkg/install/cluster.go
index 7902986..966f5ea 100644
--- a/pkg/install/cluster.go
+++ b/pkg/install/cluster.go
@@ -35,6 +35,7 @@ import (
"github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/resources"
+ "github.com/apache/camel-k/pkg/util/knative"
"github.com/apache/camel-k/pkg/util/kubernetes"
)
@@ -193,6 +194,23 @@ func SetupClusterWideResourcesOrCollect(ctx context.Context, clientProvider clie
}
}
+ isKnative, err := knative.IsInstalled(ctx, c)
+ if err != nil {
+ return err
+ }
+ if isKnative {
+ ok, err := isClusterRoleInstalled(ctx, c, "camel-k-operator-bind-addressable-resolver")
+ if err != nil {
+ return err
+ }
+ if !ok || collection != nil {
+ err := installResource(ctx, c, collection, "/rbac/operator-cluster-role-addressable-resolver.yaml")
+ if err != nil {
+ return err
+ }
+ }
+ }
+
return nil
}
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 47c5a0c..18fa8f0 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -247,44 +247,51 @@ func OperatorOrCollect(ctx context.Context, c client.Client, cfg OperatorConfigu
if err := installKnative(ctx, c, cfg.Namespace, customizer, collection, force); 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.Println("Warning: the operator will not be able to bind Knative addressable-resolver ClusterRole. Try installing the operator as cluster-admin.")
+ } else {
+ return err
+ }
+ }
}
- if errevt := installEvents(ctx, c, cfg.Namespace, customizer, collection, force); errevt != nil {
- if k8serrors.IsAlreadyExists(errevt) {
- return errevt
+ if err = installEvents(ctx, c, cfg.Namespace, customizer, collection, force); err != nil {
+ if k8serrors.IsAlreadyExists(err) {
+ return err
}
fmt.Println("Warning: the operator will not be able to publish Kubernetes events. Try installing as cluster-admin to allow it to generate events.")
}
- if errmtr := installKedaBindings(ctx, c, cfg.Namespace, customizer, collection, force); errmtr != nil {
- if k8serrors.IsAlreadyExists(errmtr) {
- return errmtr
+ if err = installKedaBindings(ctx, c, cfg.Namespace, customizer, collection, force); err != nil {
+ if k8serrors.IsAlreadyExists(err) {
+ return err
}
fmt.Println("Warning: the operator will not be able to create KEDA resources. Try installing as cluster-admin.")
}
- if errmtr := installPodMonitors(ctx, c, cfg.Namespace, customizer, collection, force); errmtr != nil {
- if k8serrors.IsAlreadyExists(errmtr) {
- return errmtr
+ if err = installPodMonitors(ctx, c, cfg.Namespace, customizer, collection, force); err != nil {
+ if k8serrors.IsAlreadyExists(err) {
+ return err
}
fmt.Println("Warning: the operator will not be able to create PodMonitor resources. Try installing as cluster-admin.")
}
- if errmtr := installStrimziBindings(ctx, c, cfg.Namespace, customizer, collection, force); errmtr != nil {
- if k8serrors.IsAlreadyExists(errmtr) {
- return errmtr
+ if err := installStrimziBindings(ctx, c, cfg.Namespace, customizer, collection, force); err != nil {
+ if k8serrors.IsAlreadyExists(err) {
+ return err
}
fmt.Println("Warning: the operator will not be able to lookup strimzi kafka resources. Try installing as cluster-admin to allow the lookup of strimzi kafka resources.")
}
- if errmtr := installLeaseBindings(ctx, c, cfg.Namespace, customizer, collection, force); errmtr != nil {
- if k8serrors.IsAlreadyExists(errmtr) {
- return errmtr
+ if err = installLeaseBindings(ctx, c, cfg.Namespace, customizer, collection, force); err != nil {
+ if k8serrors.IsAlreadyExists(err) {
+ return err
}
fmt.Println("Warning: the operator will not be able to create Leases. Try installing as cluster-admin to allow management of Lease resources.")
}
- if errmtr := installClusterRoleBinding(ctx, c, collection, cfg.Namespace, "camel-k-operator-custom-resource-definitions", "/rbac/operator-cluster-role-binding-custom-resource-definitions.yaml"); errmtr != nil {
+ if err = installClusterRoleBinding(ctx, c, collection, cfg.Namespace, "camel-k-operator-custom-resource-definitions", "/rbac/operator-cluster-role-binding-custom-resource-definitions.yaml"); err != nil {
fmt.Println("Warning: the operator will not be able to get CustomResourceDefinitions resources and the service-binding trait will fail if used. Try installing the operator as cluster-admin.")
}
@@ -309,7 +316,6 @@ func installClusterRoleBinding(ctx context.Context, c client.Client, collection
existing, err := c.RbacV1().ClusterRoleBindings().Get(ctx, name, metav1.GetOptions{})
switch {
case k8serrors.IsNotFound(err):
-
content, err := resources.ResourceAsString(path)
if err != nil {
return err
@@ -324,8 +330,10 @@ func installClusterRoleBinding(ctx context.Context, c client.Client, collection
if err != nil {
return err
}
- // nolint: forcetypeassert
- target = obj.(*rbacv1.ClusterRoleBinding)
+ var ok bool
+ if target, ok = obj.(*rbacv1.ClusterRoleBinding); !ok {
+ return fmt.Errorf("file %v does not contain a ClusterRoleBinding resource", path)
+ }
case err != nil:
return err
default:
[camel-k] 02/09: chore(doc): Document RBAC requirements for Knative Sinks
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch release-1.8.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 60b8e61ded428ade4b405ca5d340bc628bdd3ea2
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Thu Jan 27 15:43:13 2022 +0100
chore(doc): Document RBAC requirements for Knative Sinks
---
docs/modules/ROOT/nav.adoc | 1 +
.../ROOT/pages/installation/advanced/knative.adoc | 85 ++++++++++++++++++++++
2 files changed, 86 insertions(+)
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 068bf24..4e13dfe 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -16,6 +16,7 @@
*** xref:installation/registry/icr.adoc[IBM Container Registry]
*** xref:installation/registry/k3s.adoc[K3s]
** Advanced
+*** xref:installation/advanced/knative.adoc[Knative Sinks]
*** xref:installation/advanced/resources.adoc[Resource management]
*** xref:installation/advanced/multi.adoc[Multiple Operators]
* Command Line Interface
diff --git a/docs/modules/ROOT/pages/installation/advanced/knative.adoc b/docs/modules/ROOT/pages/installation/advanced/knative.adoc
new file mode 100644
index 0000000..7bb61d7
--- /dev/null
+++ b/docs/modules/ROOT/pages/installation/advanced/knative.adoc
@@ -0,0 +1,85 @@
+[[knative-sinks]]
+= Knative Sinks
+
+A https://knative.dev/docs/eventing/sinks[Knative Sink] can be referenced in a producer path of the Camel Knative component, e.g.:
+
+[source,java]
+----
+from('timer:tick')
+ .setBody().constant('event')
+ .to('knative:event/broker')
+----
+
+Or as the value of the `sink` field in a `KameletBinding` resource, e.g.:
+
+[source,yaml]
+----
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+ name: timer-source-binding
+spec:
+ source:
+ ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: timer-source
+ properties:
+ message: Event
+ sink:
+ ref:
+ kind: Broker
+ apiVersion: eventing.knative.dev/v1
+ name: broker
+ properties:
+ type: type
+----
+
+In the above examples, the Knative Sink is a https://knative.dev/docs/eventing/broker/[Knative Broker].
+However, a Knative Sink can be any Kubernetes resource that's _addressable_, i.e., whose URL can be retrieved by reading its `status.address.url`.
+
+This is what the Camel K operator does to resolve the Sink URLs, so that events can be sent to.
+That requires the ServiceAccount that runs the operator to be granted permission to GET these resources, while it configures the integration runtime.
+
+As the set of resources is arbitrary, and cannot be known _a-priori_, these permissions must be added to a Camel K operator Role, or ClusterRole, that's bound to the `camel-k-operator` ServiceAccount.
+
+For the above examples, that sink into an `eventing.knative.dev/broker` resource, this can be achieved by creating the following resources:
+
+.operator-role-knative-sinks.yaml
+[source,yaml]
+----
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRole
+metadata:
+ labels:
+ app: camel-k
+ name: camel-k-operator-knative-sinks
+rules:
+- apiGroups:
+ - eventing.knative.dev
+ resources:
+ - brokers
+ verbs:
+ - get
+----
+
+.operator-rolebinding-knative-sinks.yaml
+[source,yaml]
+----
+kind: ClusterRoleBinding
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+ name: camel-k-operator-knative-sinks
+ labels:
+ app: "camel-k"
+subjects:
+- kind: ServiceAccount
+ name: camel-k-operator
+ namespace: camel-k
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: ClusterRole
+ name: camel-k-operator-knative-sinks
+----
+
+These resources apply when the Camel K operator is deployed in _global_ mode, into the `camel-k` namespace, and should be adapted depending on how the operator is actually deployed.