Skip to content

Commit

Permalink
Adds default container annotation to Alertmanager pod (prometheus-ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephSalisbury authored Apr 13, 2021
1 parent a70c070 commit 39f8c96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pkg/alertmanager/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ func makeStatefulSetSpec(a *monitoringv1.Alertmanager, config Config) (*appsv1.S
podLabels[k] = v
}

podAnnotations["kubectl.kubernetes.io/default-container"] = "alertmanager"

var clusterPeerDomain string
if config.ClusterDomain != "" {
clusterPeerDomain = fmt.Sprintf("%s.%s.svc.%s.", governingServiceName, a.Namespace, config.ClusterDomain)
Expand Down
8 changes: 4 additions & 4 deletions pkg/alertmanager/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ func TestPodLabelsAnnotations(t *testing.T) {
},
}, nil, defaultTestConfig)
require.NoError(t, err)
if _, ok := sset.Spec.Template.ObjectMeta.Labels["testlabel"]; !ok {
t.Fatal("Pod labes are not properly propagated")
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) {
t.Fatal("Pod annotaitons are not properly propagated")
if val, ok := sset.Spec.Template.ObjectMeta.Annotations["testannotation"]; !ok || val != "testvalue" {
t.Fatal("Pod annotations are not properly propagated")
}
}

Expand Down

0 comments on commit 39f8c96

Please sign in to comment.