Skip to content

Commit e3cb73c

Browse files
alunguamuraru
authored andcommitted
Remove Prometheus scraping hardcoded annotations (#10)
We can add them using `brokerAnnotations` CR value. Also, this opens up the possibility to use ServiceMonitors instead of scraping annotations.
1 parent 2d191ba commit e3cb73c

File tree

4 files changed

+3
-26
lines changed

4 files changed

+3
-26
lines changed

pkg/resources/cruisecontrol/deployment.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ func GeneratePodAnnotations(kafkaCluster *v1beta1.KafkaCluster, log logr.Logger,
185185
"cruiseControlConfig.json": hex.EncodeToString(hashedCruiseControlConfigJson[:]),
186186
"cruiseControlClusterConfig.json": hex.EncodeToString(hashedCruiseControlClusterConfigJson[:]),
187187
},
188-
util.MonitoringAnnotations(metricsPort),
189188
}
190189

191190
return util.MergeAnnotations(annotations...)

pkg/resources/kafka/pod.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,13 @@ fi
102102
}
103103

104104
pod := &corev1.Pod{
105-
ObjectMeta: templates.ObjectMetaWithGeneratedNameAndAnnotations(
105+
ObjectMeta: templates.ObjectMetaWithGeneratedName(
106106
fmt.Sprintf("%s-%d-", r.KafkaCluster.Name, id),
107107
util.MergeLabels(
108108
LabelsForKafka(r.KafkaCluster.Name),
109109
map[string]string{"brokerId": fmt.Sprintf("%d", id)},
110110
),
111-
util.MergeAnnotations(
112-
brokerConfig.GetBrokerAnnotations(),
113-
util.MonitoringAnnotations(metricsPort),
114-
), r.KafkaCluster,
111+
r.KafkaCluster,
115112
),
116113
Spec: corev1.PodSpec{
117114
InitContainers: append(initContainers, []corev1.Container{

pkg/util/util.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ func MergeLabels(l ...map[string]string) map[string]string {
9191
return res
9292
}
9393

94-
// MonitoringAnnotations returns specific prometheus annotations
95-
func MonitoringAnnotations(port int) map[string]string {
96-
return map[string]string{
97-
"prometheus.io/scrape": "true",
98-
"prometheus.io/port": strconv.Itoa(port),
99-
}
100-
}
101-
10294
func MergeAnnotations(annotations ...map[string]string) map[string]string {
10395
rtn := make(map[string]string)
10496
for _, a := range annotations {

pkg/util/util_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,6 @@ func TestMergeLabels(t *testing.T) {
183183
}
184184
}
185185

186-
func TestMonitoringAnnotations(t *testing.T) {
187-
expected := map[string]string{
188-
"prometheus.io/scrape": "true",
189-
"prometheus.io/port": "9001",
190-
}
191-
anntns := MonitoringAnnotations(int(9001))
192-
if !reflect.DeepEqual(expected, anntns) {
193-
t.Error("Expected:", expected, "Got:", anntns)
194-
}
195-
}
196-
197186
func TestConvertStringToInt32(t *testing.T) {
198187
i := ConvertStringToInt32("10")
199188
if i != 10 {
@@ -244,7 +233,7 @@ func TestStringSliceRemove(t *testing.T) {
244233
}
245234

246235
func TestMergeAnnotations(t *testing.T) {
247-
annotations := MonitoringAnnotations(8888)
236+
annotations := map[string]string{"foo": "bar", "bar": "foo"}
248237
annotations2 := map[string]string{"thing": "1", "other_thing": "2"}
249238

250239
combined := MergeAnnotations(annotations, annotations2)

0 commit comments

Comments
 (0)