Skip to content

Commit 3dbd157

Browse files
authored
Use Prometheus TLS port if TLS is enabled (#672)
When TLS is enabled use the prometheus-tls port in the annotation. This matches the behaviour of the Service: When TLS is enabled, port 15691 is exposed in the Service.
1 parent e849acd commit 3dbd157

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

internal/resource/statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func sortVolumeMounts(mounts []corev1.VolumeMount) {
302302
func (builder *StatefulSetBuilder) podTemplateSpec(previousPodAnnotations map[string]string) corev1.PodTemplateSpec {
303303
// default pod annotations used for prometheus metrics
304304
prometheusPort := "15692"
305-
if builder.Instance.DisableNonTLSListeners() {
305+
if builder.Instance.TLSEnabled() {
306306
prometheusPort = "15691"
307307
}
308308

internal/resource/statefulset_test.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,18 @@ var _ = Describe("StatefulSet", func() {
564564
})
565565
})
566566

567+
When("TLS is enabled", func() {
568+
It("updates Prometheus port", func() {
569+
stsBuilder.Instance.Spec.TLS.SecretName = "tls-secret"
570+
Expect(stsBuilder.Update(statefulSet)).To(Succeed())
571+
expectedPodAnnotations := map[string]string{
572+
"prometheus.io/scrape": "true",
573+
"prometheus.io/port": "15691",
574+
}
575+
Expect(statefulSet.Spec.Template.Annotations).To(Equal(expectedPodAnnotations))
576+
})
577+
})
578+
567579
Context("annotation inheritance", func() {
568580
var (
569581
existingAnnotations map[string]string
@@ -659,21 +671,6 @@ var _ = Describe("StatefulSet", func() {
659671

660672
Expect(statefulSet.Spec.VolumeClaimTemplates[0].Annotations).To(Equal(expectedAnnotations))
661673
})
662-
663-
When("non-TLS listeners get disabled", func() {
664-
It("updates pod annotations", func() {
665-
stsBuilder.Instance.Spec.TLS.DisableNonTLSListeners = true
666-
Expect(stsBuilder.Update(statefulSet)).To(Succeed())
667-
668-
expectedPodAnnotations := map[string]string{
669-
"prometheus.io/scrape": "true",
670-
"prometheus.io/port": "15691",
671-
"this-was-the-previous-pod-anno": "should-be-preserved",
672-
}
673-
674-
Expect(statefulSet.Spec.Template.Annotations).To(Equal(expectedPodAnnotations))
675-
})
676-
})
677674
})
678675
})
679676

0 commit comments

Comments
 (0)