Skip to content

Commit e941094

Browse files
authored
fix: openshift-gitops-operator-metrics-monitor ServiceMonitor is attempting to use a bearerTokenFile configuration in its endpoints definition (#1005)
* fix: openshift-gitops-operator-metrics-monitor ServiceMonitor is attempting to use a bearerTokenFile configuration in its endpoints definition Signed-off-by: akhil nittala <[email protected]> * fix: openshift-gitops-operator-metrics-monitor ServiceMonitor is attempting to use a bearerTokenFile configuration in its endpoints definition Signed-off-by: akhil nittala <[email protected]> * fix: openshift-gitops-operator-metrics-monitor ServiceMonitor is attempting to use a bearerTokenFile configuration in its endpoints definition Signed-off-by: akhil nittala <[email protected]> * fix: openshift-gitops-operator-metrics-monitor ServiceMonitor is attempting to use a bearerTokenFile configuration in its endpoints definition Signed-off-by: akhil nittala <[email protected]> * fix: openshift-gitops-operator-metrics-monitor ServiceMonitor is attempting to use a bearerTokenFile configuration in its endpoints definition Signed-off-by: akhil nittala <[email protected]> * fix: openshift-gitops-operator-metrics-monitor ServiceMonitor is attempting to use a bearerTokenFile configuration in its endpoints definition Signed-off-by: akhil nittala <[email protected]> --------- Signed-off-by: akhil nittala <[email protected]>
1 parent bbd99d5 commit e941094

File tree

5 files changed

+82
-24
lines changed

5 files changed

+82
-24
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
annotations:
5+
kubernetes.io/service-account.name: openshift-gitops-operator-controller-manager
6+
name: openshift-gitops-operator-metrics-bearer-token
7+
type: kubernetes.io/service-account-token
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
annotations:
5+
openshift.io/description: This ConfigMap is used for Prometheus monitoring of
6+
the GitOps Operator.
7+
openshift.io/display-name: GitOps Operator Prometheus Monitor ConfigMap
8+
openshift.io/owning-component: service-ca
9+
service.beta.openshift.io/inject-cabundle: "true"
10+
name: openshift-gitops-operator-metrics-monitor-ca-bundle

bundle/manifests/openshift-gitops-operator-metrics-monitor_monitoring.coreos.com_v1_servicemonitor.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ metadata:
66
name: openshift-gitops-operator-metrics-monitor
77
spec:
88
endpoints:
9-
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
9+
- bearerTokenSecret:
10+
key: token
11+
name: openshift-gitops-operator-metrics-bearer-token
1012
interval: 30s
1113
path: /metrics
1214
port: metrics
1315
scheme: https
1416
tlsConfig:
15-
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
17+
ca:
18+
configMap:
19+
key: service-ca.crt
20+
name: openshift-gitops-operator-metrics-monitor-ca-bundle
1621
serverName: openshift-gitops-operator-metrics-service.openshift-gitops-operator.svc
1722
selector:
1823
matchLabels:

config/prometheus/monitor.yaml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
1-
2-
# Prometheus Monitor Service (Metrics)
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: metrics-bearer-token
6+
namespace: openshift-gitops-operator
7+
annotations:
8+
kubernetes.io/service-account.name: openshift-gitops-operator-controller-manager
9+
type: kubernetes.io/service-account-token
10+
---
11+
apiVersion: v1
12+
kind: ConfigMap
13+
metadata:
14+
annotations:
15+
openshift.io/description: This ConfigMap is used for Prometheus monitoring of the GitOps Operator.
16+
openshift.io/display-name: GitOps Operator Prometheus Monitor ConfigMap
17+
openshift.io/owning-component: service-ca
18+
service.beta.openshift.io/inject-cabundle: "true"
19+
name: metrics-monitor-ca-bundle
20+
namespace: openshift-gitops-operator
21+
---
322
apiVersion: monitoring.coreos.com/v1
423
kind: ServiceMonitor
524
metadata:
25+
name: metrics-monitor
26+
namespace: openshift-gitops-operator
627
labels:
728
control-plane: gitops-operator
8-
name: metrics-monitor
9-
namespace: system
1029
spec:
30+
selector:
31+
matchLabels:
32+
control-plane: gitops-operator
1133
endpoints:
12-
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
13-
path: /metrics
34+
- bearerTokenSecret:
35+
name: openshift-gitops-operator-metrics-bearer-token
36+
key: token
1437
interval: 30s
38+
path: /metrics
1539
port: metrics
1640
scheme: https
1741
tlsConfig:
18-
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
42+
ca:
43+
configMap:
44+
name: openshift-gitops-operator-metrics-monitor-ca-bundle
45+
key: service-ca.crt
1946
serverName: openshift-gitops-operator-metrics-service.openshift-gitops-operator.svc
20-
selector:
21-
matchLabels:
22-
control-plane: gitops-operator

test/openshift/e2e/ginkgo/parallel/1-104_validate_prometheus_alert_test.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ package parallel
33
import (
44
. "github.com/onsi/ginkgo/v2"
55
. "github.com/onsi/gomega"
6+
67
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
8+
corev1 "k8s.io/api/core/v1"
9+
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
712
"github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture"
813
k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s"
9-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1014
)
1115

1216
var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
1317

1418
Context("1-104_validate_prometheus_alert", func() {
1519

1620
BeforeEach(func() {
17-
1821
fixture.EnsureParallelCleanSlate()
1922
})
2023

@@ -33,19 +36,29 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
3336
}
3437
Eventually(sm).Should(k8sFixture.ExistByName())
3538

36-
Expect(sm.Spec.Endpoints).Should(Equal([]monitoringv1.Endpoint{{
37-
BearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token",
38-
Interval: monitoringv1.Duration("30s"),
39-
Path: "/metrics",
40-
Port: "metrics",
41-
Scheme: "https",
39+
Expect(sm.Spec.Endpoints).To(Equal([]monitoringv1.Endpoint{{
40+
BearerTokenSecret: &corev1.SecretKeySelector{
41+
LocalObjectReference: corev1.LocalObjectReference{
42+
Name: "openshift-gitops-operator-metrics-bearer-token",
43+
},
44+
Key: "token",
45+
},
46+
Interval: monitoringv1.Duration("30s"),
47+
Path: "/metrics",
48+
Port: "metrics",
49+
Scheme: "https",
4250
TLSConfig: &monitoringv1.TLSConfig{
4351
SafeTLSConfig: monitoringv1.SafeTLSConfig{
44-
CA: monitoringv1.SecretOrConfigMap{},
45-
Cert: monitoringv1.SecretOrConfigMap{},
52+
CA: monitoringv1.SecretOrConfigMap{
53+
ConfigMap: &corev1.ConfigMapKeySelector{
54+
LocalObjectReference: corev1.LocalObjectReference{
55+
Name: "openshift-gitops-operator-metrics-monitor-ca-bundle",
56+
},
57+
Key: "service-ca.crt",
58+
},
59+
},
4660
ServerName: "openshift-gitops-operator-metrics-service.openshift-gitops-operator.svc",
4761
},
48-
CAFile: "/etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt",
4962
},
5063
}}))
5164

@@ -57,5 +70,4 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
5770
}))
5871
})
5972
})
60-
6173
})

0 commit comments

Comments
 (0)