diff --git a/pkg/thanos/statefulset.go b/pkg/thanos/statefulset.go index 297d3bae229..e79c7196547 100644 --- a/pkg/thanos/statefulset.go +++ b/pkg/thanos/statefulset.go @@ -358,6 +358,8 @@ func makeStatefulSetSpec(tr *monitoringv1.ThanosRuler, config Config, ruleConfig podLabels[thanosRulerLabel] = tr.Name finalLabels := config.Labels.Merge(podLabels) + podAnnotations["kubectl.kubernetes.io/default-container"] = "thanos-ruler" + storageVolName := volumeName(tr.Name) if tr.Spec.Storage != nil { if tr.Spec.Storage.VolumeClaimTemplate.Name != "" { diff --git a/pkg/thanos/statefulset_test.go b/pkg/thanos/statefulset_test.go index 68f96387dda..0cf111b54f3 100644 --- a/pkg/thanos/statefulset_test.go +++ b/pkg/thanos/statefulset_test.go @@ -101,10 +101,10 @@ func TestPodLabelsAnnotations(t *testing.T) { }, }, defaultTestConfig, nil, "") require.NoError(t, err) - if _, ok := sset.Spec.Template.ObjectMeta.Labels["testlabel"]; !ok { + if val, ok := sset.Spec.Template.ObjectMeta.Labels["testlabel"]; !ok || val != "testvalue" { t.Fatal("Pod labels are not properly propagated") } - if !reflect.DeepEqual(annotations, sset.Spec.Template.ObjectMeta.Annotations) { + if val, ok := sset.Spec.Template.ObjectMeta.Annotations["testannotation"]; !ok || val != "testvalue" { t.Fatal("Pod annotations are not properly propagated") } }