Skip to content

Commit 86ca964

Browse files
geoffrey1330bacherflmowiesodubajDT
authored andcommitted
feat(metrics-operator): add helm value to disable APIService installation (#2607)
Signed-off-by: Geoffrey Israel <[email protected]> Co-authored-by: Florian Bacher <[email protected]> Co-authored-by: Moritz Wiesinger <[email protected]> Co-authored-by: odubajDT <[email protected]> Signed-off-by: David Ahmadov <[email protected]>
1 parent 77086c4 commit 86ca964

File tree

14 files changed

+2475
-6
lines changed

14 files changed

+2475
-6
lines changed

.github/actions/spelling/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ annadreal
2828
apicommon
2929
apierr
3030
apierrors
31+
apiservice
3132
APIURL
3233
apk
3334
appcreationrequest

.github/scripts/.helm-tests/default/result.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9265,6 +9265,8 @@ spec:
92659265
fieldPath: metadata.name
92669266
- name: EXPOSE_KEPTN_METRICS
92679267
value: "true"
9268+
- name: ENABLE_CUSTOM_METRICS_API_SERVICE
9269+
value: "true"
92689270
- name: METRICS_CONTROLLER_LOG_LEVEL
92699271
value: "0"
92709272
- name: ANALYSIS_CONTROLLER_LOG_LEVEL

.github/scripts/.helm-tests/metrics-only-with-apiservice-disabled/result.yaml

Lines changed: 2431 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
certManager:
2+
enabled: false
3+
lifecycleOperator:
4+
enabled: false
5+
metricsOperator:
6+
enabled: true
7+
image:
8+
tag: v0.0.0
9+
customMetricsAPIService:
10+
enabled: "false"
11+
12+
global:
13+
commonLabels:
14+
app.kubernetes.io/version: vmyversion

.github/scripts/.helm-tests/metrics-only/result.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,6 +2308,8 @@ spec:
23082308
fieldPath: metadata.name
23092309
- name: EXPOSE_KEPTN_METRICS
23102310
value: "true"
2311+
- name: ENABLE_CUSTOM_METRICS_API_SERVICE
2312+
value: "true"
23112313
- name: METRICS_CONTROLLER_LOG_LEVEL
23122314
value: "0"
23132315
- name: ANALYSIS_CONTROLLER_LOG_LEVEL

.github/scripts/.helm-tests/metrics-with-certs/result.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,8 @@ spec:
25642564
fieldPath: metadata.name
25652565
- name: EXPOSE_KEPTN_METRICS
25662566
value: "true"
2567+
- name: ENABLE_CUSTOM_METRICS_API_SERVICE
2568+
value: "true"
25672569
- name: METRICS_CONTROLLER_LOG_LEVEL
25682570
value: "0"
25692571
- name: ANALYSIS_CONTROLLER_LOG_LEVEL

metrics-operator/chart/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Prometheus, Dynatrace, DataDog and K8s metric server...
5656
| `annotations` | add deployment level annotations | `{}` |
5757
| `podAnnotations` | adds pod level annotations | `{}` |
5858
| `kubernetesClusterDomain` | overrides cluster.local | `cluster.local` |
59+
| `customMetricsAPIService.enabled` | enable/disable the K8s APIService installation | `true` |
5960

6061
### Keptn Metrics Operator controller
6162

metrics-operator/chart/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ spec:
4747
fieldPath: metadata.name
4848
- name: EXPOSE_KEPTN_METRICS
4949
value: {{ .Values.env.exposeKeptnMetrics | quote }}
50+
- name: ENABLE_CUSTOM_METRICS_API_SERVICE
51+
value: {{ .Values.customMetricsAPIService.enabled | quote }}
5052
- name: METRICS_CONTROLLER_LOG_LEVEL
5153
value: {{ .Values.env.metricsControllerLogLevel | quote
5254
}}

metrics-operator/chart/templates/metrics-operator-hpa-controller-rbac.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if eq .Values.customMetricsAPIService.enabled "true" }}
12
apiVersion: rbac.authorization.k8s.io/v1
23
kind: ClusterRoleBinding
34
metadata:
@@ -13,4 +14,5 @@ roleRef:
1314
subjects:
1415
- kind: ServiceAccount
1516
name: horizontal-pod-autoscaler
16-
namespace: '{{ .Release.Namespace }}'
17+
namespace: '{{ .Release.Namespace }}'
18+
{{- end }}

metrics-operator/chart/templates/v1beta1.custom.metrics.k8s.io.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if eq .Values.customMetricsAPIService.enabled "true" }}
12
apiVersion: apiregistration.k8s.io/v1
23
kind: APIService
34
metadata:
@@ -14,4 +15,5 @@ spec:
1415
name: 'metrics-operator-service'
1516
namespace: '{{ .Release.Namespace }}'
1617
version: v1beta1
17-
versionPriority: 100
18+
versionPriority: 100
19+
{{- end }}

metrics-operator/chart/templates/v1beta2.custom.metrics.k8s.io.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if eq .Values.customMetricsAPIService.enabled "true" }}
12
apiVersion: apiregistration.k8s.io/v1
23
kind: APIService
34
metadata:
@@ -14,4 +15,5 @@ spec:
1415
name: 'metrics-operator-service'
1516
namespace: '{{ .Release.Namespace }}'
1617
version: v1beta2
17-
versionPriority: 200
18+
versionPriority: 200
19+
{{- end }}

metrics-operator/chart/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ annotations: {}
9393
podAnnotations: {}
9494
## @param kubernetesClusterDomain overrides cluster.local
9595
kubernetesClusterDomain: cluster.local
96+
customMetricsAPIService:
97+
## @param customMetricsAPIService.enabled enable/disable the K8s APIService installation
98+
enabled: "true"
9699

97100
## @section Keptn Metrics Operator controller
98101
## @extra containerSecurityContext Sets security context privileges

metrics-operator/config/manager/manager.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ spec:
6565
fieldPath: metadata.name
6666
- name: EXPOSE_KEPTN_METRICS
6767
value: "true"
68+
- name: ENABLE_CUSTOM_METRICS_API_SERVICE
69+
value: "true"
6870
- name: ENABLE_ANALYSIS
6971
value: "true"
7072
- name: METRICS_CONTROLLER_LOG_LEVEL

metrics-operator/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type envConfig struct {
7272
KeptnMetricControllerLogLevel int `envconfig:"METRICS_CONTROLLER_LOG_LEVEL" default:"0"`
7373
AnalysisControllerLogLevel int `envconfig:"ANALYSIS_CONTROLLER_LOG_LEVEL" default:"0"`
7474
ExposeKeptnMetrics bool `envconfig:"EXPOSE_KEPTN_METRICS" default:"true"`
75+
EnableCustomMetricsAPIService bool `envconfig:"ENABLE_CUSTOM_METRICS_API_SERVICE" default:"true"`
7576
}
7677

7778
//nolint:gocyclo,funlen
@@ -133,9 +134,10 @@ func main() {
133134
return
134135
}
135136

136-
// Start the custom metrics adapter
137-
go startCustomMetricsAdapter(env.PodNamespace)
138-
137+
if env.EnableCustomMetricsAPIService {
138+
// Start the custom metrics adapter
139+
go startCustomMetricsAdapter(env.PodNamespace)
140+
}
139141
disableCacheFor := []ctrlclient.Object{&corev1.Secret{}}
140142

141143
opt := ctrl.Options{
@@ -182,6 +184,7 @@ func main() {
182184

183185
ctx, cancel := context.WithCancel(context.Background())
184186
defer cancel()
187+
185188
keptnserver.StartServerManager(ctx, mgr.GetClient(), openfeature.NewClient("keptn"), env.ExposeKeptnMetrics, metricServerTickerInterval)
186189

187190
metricsLogger := ctrl.Log.WithName("KeptnMetric Controller")

0 commit comments

Comments
 (0)