Skip to content

Commit

Permalink
fix(#4948): changed platformcontroller component name lable and annot…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
valdar committed Feb 14, 2024
1 parent 7aaffa8 commit 7cfce32
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 20 deletions.
12 changes: 6 additions & 6 deletions config/manager/platformcontroller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ metadata:
name: camel-k-platformcontroller
labels:
app: "camel-k"
camel.apache.org/component: operator
camel.apache.org/component: platformcontroller
name: camel-k-platformcontroller
app.kubernetes.io/component: operator
app.kubernetes.io/name: camel-k
app.kubernetes.io/component: platformcontroller
app.kubernetes.io/name: camel-k-platformcontroller
app.kubernetes.io/version: "2.3.0-SNAPSHOT"
spec:
replicas: 1
Expand All @@ -37,10 +37,10 @@ spec:
metadata:
labels:
name: camel-k-platformcontroller
camel.apache.org/component: operator
camel.apache.org/component: platformcontroller
app: "camel-k"
app.kubernetes.io/component: operator
app.kubernetes.io/name: camel-k
app.kubernetes.io/component: platformcontroller
app.kubernetes.io/name: camel-k-platformcontroller
app.kubernetes.io/version: "2.3.0-SNAPSHOT"
spec:
serviceAccountName: camel-k-operator
Expand Down
2 changes: 1 addition & 1 deletion config/manifests/bases/camel-k.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:
categories: Integration & Delivery
certified: "false"
containerImage: docker.io/apache/camel-k:2.3.0-SNAPSHOT
createdAt: 2024-01-08T10:32:24Z
createdAt: 2024-02-13T21:56:07Z
description: Apache Camel K is a lightweight integration platform, born on Kubernetes,
with serverless superpowers.
operators.operatorframework.io/builder: operator-sdk-v1.16.0
Expand Down
2 changes: 2 additions & 0 deletions config/prometheus/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
resources:
- operator-pod-monitor.yaml
- operator-prometheus-rule.yaml
- platformcontroller-pod-monitor.yaml
- platformcontroller-prometheus-rule.yaml
31 changes: 31 additions & 0 deletions config/prometheus/platformcontroller-pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------

apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: camel-k-platformcontroller
labels:
app: "camel-k"
camel.apache.org/component: platformcontroller
spec:
selector:
matchLabels:
app: "camel-k"
camel.apache.org/component: platformcontroller
podMetricsEndpoints:
- port: metrics
55 changes: 55 additions & 0 deletions config/prometheus/platformcontroller-prometheus-rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: camel-k-platformcontroller
spec:
groups:
- name: camel-k-platformcontroller
rules:
- alert: CamelKReconciliationDuration
expr: |
(
1 - sum(rate(camel_k_reconciliation_duration_seconds_bucket{le="0.5"}[5m])) by (job)
/
sum(rate(camel_k_reconciliation_duration_seconds_count[5m])) by (job)
)
* 100
> 10
for: 1m
labels:
severity: warning
annotations:
message: |
{{ printf "%0.0f" $value }}% of the reconciliation requests
for {{ $labels.job }} have their duration above 0.5s.
- alert: CamelKReconciliationFailure
expr: |
sum(rate(camel_k_reconciliation_duration_seconds_count{result="Errored"}[5m])) by (job)
/
sum(rate(camel_k_reconciliation_duration_seconds_count[5m])) by (job)
* 100
> 1
for: 10m
labels:
severity: warning
annotations:
message: |
{{ printf "%0.0f" $value }}% of the reconciliation requests
for {{ $labels.job }} have failed.
4 changes: 2 additions & 2 deletions helm/camel-k/templates/platformcontroller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ kind: Deployment
metadata:
labels:
app: camel-k
camel.apache.org/component: operator
camel.apache.org/component: platformcontroller
{{- include "camel-k.labels" . | nindent 4 }}
{{- with .Values.operator.annotations }}
annotations:
Expand All @@ -38,7 +38,7 @@ spec:
metadata:
labels:
app: camel-k
camel.apache.org/component: operator
camel.apache.org/component: platformcontroller
name: camel-k-platformcontroller
spec:
{{- if .Values.operator.imagePullSecrets }}
Expand Down
18 changes: 9 additions & 9 deletions pkg/install/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
customizer := func(o ctrl.Object) ctrl.Object {
if cfg.CustomImage != "" {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
d.Spec.Template.Spec.Containers[0].Image = cfg.CustomImage
}
}
}

if cfg.CustomImagePullPolicy != "" {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
d.Spec.Template.Spec.Containers[0].ImagePullPolicy = corev1.PullPolicy(cfg.CustomImagePullPolicy)
}
}
}

if cfg.Tolerations != nil {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
tolerations, err := kubernetes.NewTolerations(cfg.Tolerations)
if err != nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Warning: could not parse the configured tolerations!")
Expand All @@ -125,7 +125,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,

if cfg.ResourcesRequirements != nil {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
resourceReq, err := kubernetes.NewResourceRequirements(cfg.ResourcesRequirements)
if err != nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Warning: could not parse the configured resources requests!")
Expand All @@ -139,7 +139,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,

if cfg.EnvVars != nil {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
envVars, _, _, err := env.ParseEnv(cfg.EnvVars, nil)
if err != nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Warning: could not parse environment variables!")
Expand All @@ -153,7 +153,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,

if cfg.NodeSelectors != nil {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
nodeSelector, err := kubernetes.NewNodeSelectors(cfg.NodeSelectors)
if err != nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Warning: could not parse the configured node selectors!")
Expand All @@ -164,7 +164,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
}

if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
// Metrics endpoint port
d.Spec.Template.Spec.Containers[0].Args = append(d.Spec.Template.Spec.Containers[0].Args,
fmt.Sprintf("--monitoring-port=%d", cfg.Monitoring.Port))
Expand All @@ -177,7 +177,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
}
if cfg.Debugging.Enabled {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
d.Spec.Template.Spec.Containers[0].Command = []string{"dlv",
fmt.Sprintf("--listen=:%d", cfg.Debugging.Port), "--headless=true", "--api-version=2",
"exec", cfg.Debugging.Path, "--", "operator", "--leader-election=false"}
Expand All @@ -194,7 +194,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,

if cfg.Global {
if d, ok := o.(*appsv1.Deployment); ok {
if d.Labels["camel.apache.org/component"] == "operator" {
if d.Labels["camel.apache.org/component"] == "operator" || d.Labels["camel.apache.org/component"] == "platformcontroller" {
// Make the operator watch all namespaces
envvar.SetVal(&d.Spec.Template.Spec.Containers[0].Env, "WATCH_NAMESPACE", "")
}
Expand Down
Loading

0 comments on commit 7cfce32

Please sign in to comment.