You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2020/05/07 07:20:03 UTC
[camel-k] branch master updated: Fix #1450: fix servicemonitor
roles on direct install
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new 8e2fa97 Fix #1450: fix servicemonitor roles on direct install
8e2fa97 is described below
commit 8e2fa97704bed7b350995554efef9748ecfa33ee
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Wed May 6 16:15:33 2020 +0200
Fix #1450: fix servicemonitor roles on direct install
---
deploy/operator-role-binding-servicemonitors.yaml | 30 ++++++++++++++++++
deploy/operator-role-servicemonitors.yaml | 37 +++++++++++++++++++++++
deploy/resources.go | 16 ++++++++++
pkg/install/operator.go | 18 +++++++++--
4 files changed, 99 insertions(+), 2 deletions(-)
diff --git a/deploy/operator-role-binding-servicemonitors.yaml b/deploy/operator-role-binding-servicemonitors.yaml
new file mode 100644
index 0000000..cb49320
--- /dev/null
+++ b/deploy/operator-role-binding-servicemonitors.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/v1beta1
+metadata:
+ name: camel-k-operator-servicemonitors
+ labels:
+ app: "camel-k"
+subjects:
+- kind: ServiceAccount
+ name: camel-k-operator
+roleRef:
+ kind: Role
+ name: camel-k-operator-servicemonitors
+ apiGroup: rbac.authorization.k8s.io
diff --git a/deploy/operator-role-servicemonitors.yaml b/deploy/operator-role-servicemonitors.yaml
new file mode 100644
index 0000000..aae49c0
--- /dev/null
+++ b/deploy/operator-role-servicemonitors.yaml
@@ -0,0 +1,37 @@
+# ---------------------------------------------------------------------------
+# 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: Role
+apiVersion: rbac.authorization.k8s.io/v1beta1
+metadata:
+ name: camel-k-operator-servicemonitors
+ labels:
+ app: "camel-k"
+rules:
+- apiGroups:
+ - monitoring.coreos.com
+ resources:
+ - servicemonitors
+ verbs:
+ - create
+ - delete
+ - deletecollection
+ - get
+ - list
+ - patch
+ - update
+ - watch
diff --git a/deploy/resources.go b/deploy/resources.go
index 0f3469a..e884007 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -165,6 +165,13 @@ var assets = func() http.FileSystem {
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\xd6\x72\xd3\x53\xe1\x9e\x9c\xcd\x6e\x2b\x34\xb0\x01\xcb\x69\x90\xe3\x88\x1a\x4b\x53\x4b\x1c\x95\xa4\x56\x71\x7f\x7d\x41\xd9\xee\x6e\x50\xb4\xc8\x61\x79\x13\x34\x7a\xf3\x3d\xbe\xa7\x0c\xcb\xd7\x3b\x26\xc3\x47\xb1\xec\x02\xd7\x88\x8a\xd8\x32\x36\x03\xd9\x96\x51\xea\x31\x4e\xe4\x19\x8f\x3a\xba\x9a\xa2\xa8\xc3\x9b\x4d\xf9\xf8\x16\xa3\xab\xd9\x43\x1d\x43\x3d\x7a\x [...]
},
+ "/operator-role-binding-servicemonitors.yaml": &vfsgen۰CompressedFileInfo{
+ name: "operator-role-binding-servicemonitors.yaml",
+ modTime: time.Time{},
+ uncompressedSize: 1242,
+
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x6f\xdb\x46\x10\xbd\xef\xaf\x78\x10\x2f\x09\x60\x51\x4d\x4f\x85\x7a\x52\x1c\xbb\x25\x1a\x48\x80\xa8\x34\xc8\x71\x44\x8e\xc8\xa9\xc9\x1d\x76\x76\x69\xc6\xfd\xf5\xc5\x52\x52\xed\xa0\x68\x81\x00\xde\x9b\xa0\x99\xf7\x31\xef\x31\xc3\xf2\xf5\x9e\xcb\xf0\x51\x2a\xf6\x81\x6b\x44\x45\x6c\x19\x9b\x81\xaa\x96\x51\xea\x29\x4e\x64\x8c\x7b\x1d\x7d\x4d\x51\xd4\xe3\xcd\xa6\xbc\x7f\x8b\xd1\xd7\x6c\x50\xcf\x50\x43\xaf\xc6\x [...]
+ },
"/operator-role-binding.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-role-binding.yaml",
modTime: time.Time{},
@@ -214,6 +221,13 @@ var assets = func() http.FileSystem {
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x54\xc1\x8e\xdb\x46\x0c\xbd\xeb\x2b\x08\xe9\x92\x14\x6b\xb9\xe9\xa9\x70\x4f\x6e\xb2\xdb\x1a\x0d\xbc\xc0\xca\x69\x90\x23\x35\xa2\x25\x76\x47\xc3\xe9\xcc\xc8\x8a\xfb\xf5\x85\x46\x72\x62\xaf\x76\x91\x16\x08\x60\x5f\x4c\x71\xa8\xc7\xc7\xf7\xa8\xc9\x60\xf1\xfd\x7e\x49\x06\xef\x59\x91\xf1\x54\x41\x10\x08\x0d\xc1\xda\xa2\x6a\x08\x0a\xd9\x87\x1e\x1d\xc1\x9d\x74\xa6\xc2\xc0\x62\xe0\xd5\xba\xb8\x7b\x0d\x9d\xa9\xc8\x81\x18\x [...]
},
+ "/operator-role-servicemonitors.yaml": &vfsgen۰CompressedFileInfo{
+ name: "operator-role-servicemonitors.yaml",
+ modTime: time.Time{},
+ uncompressedSize: 1255,
+
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xc1\x6e\xdb\x46\x10\xbd\xef\x57\x3c\x88\x97\x04\xb0\xa8\xa6\xa7\x42\x3d\xa9\x8e\xdd\x12\x0d\x24\xc0\x54\x1a\xe4\xb8\x5a\x8e\xc8\x81\x97\x3b\xec\xec\xd2\x8c\xfb\xf5\x05\x57\x54\x62\x23\x57\xef\x45\xa3\xdd\x99\x79\xef\xcd\x1b\x16\x58\xbf\xdd\x31\x05\x3e\xb1\xa3\x10\xa9\x41\x12\xa4\x8e\xb0\x1b\xac\xeb\x08\xb5\x9c\xd3\x64\x95\x70\x2f\x63\x68\x6c\x62\x09\x78\xb7\xab\xef\xdf\x63\x0c\x0d\x29\x24\x10\x44\xd1\x8b\x92\x [...]
+ },
"/operator-service-account.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-service-account.yaml",
modTime: time.Time{},
@@ -369,6 +383,7 @@ var assets = func() http.FileSystem {
fs["/operator-deployment.yaml"].(os.FileInfo),
fs["/operator-role-binding-events.yaml"].(os.FileInfo),
fs["/operator-role-binding-knative.yaml"].(os.FileInfo),
+ fs["/operator-role-binding-servicemonitors.yaml"].(os.FileInfo),
fs["/operator-role-binding.yaml"].(os.FileInfo),
fs["/operator-role-events.yaml"].(os.FileInfo),
fs["/operator-role-knative.yaml"].(os.FileInfo),
@@ -376,6 +391,7 @@ var assets = func() http.FileSystem {
fs["/operator-role-olm-cluster.yaml"].(os.FileInfo),
fs["/operator-role-olm.yaml"].(os.FileInfo),
fs["/operator-role-openshift.yaml"].(os.FileInfo),
+ fs["/operator-role-servicemonitors.yaml"].(os.FileInfo),
fs["/operator-service-account.yaml"].(os.FileInfo),
fs["/platform-cr.yaml"].(os.FileInfo),
fs["/platform-integration-kit-groovy.yaml"].(os.FileInfo),
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index a12b27b..d156162 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -130,12 +130,19 @@ func OperatorOrCollect(ctx context.Context, c client.Client, cfg OperatorConfigu
}
if errevt := installEvents(ctx, c, cfg.Namespace, customizer, collection, force); errevt != nil {
- if k8serrors.IsAlreadyExists(err) {
- return err
+ if k8serrors.IsAlreadyExists(errevt) {
+ return errevt
}
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 := installServiceMonitors(ctx, c, cfg.Namespace, customizer, collection, force); errmtr != nil {
+ if k8serrors.IsAlreadyExists(errmtr) {
+ return errmtr
+ }
+ fmt.Println("Warning: the operator will not be able to create servicemonitors for metrics. Try installing as cluster-admin to allow the creation of servicemonitors.")
+ }
+
return nil
}
@@ -171,6 +178,13 @@ func installEvents(ctx context.Context, c client.Client, namespace string, custo
)
}
+func installServiceMonitors(ctx context.Context, c client.Client, namespace string, customizer ResourceCustomizer, collection *kubernetes.Collection, force bool) error {
+ return ResourcesOrCollect(ctx, c, namespace, collection, force, customizer,
+ "operator-role-servicemonitors.yaml",
+ "operator-role-binding-servicemonitors.yaml",
+ )
+}
+
// Platform installs the platform custom resource
// nolint: lll
func Platform(ctx context.Context, c client.Client, clusterType string, namespace string, registry v1.IntegrationPlatformRegistrySpec) (*v1.IntegrationPlatform, error) {