Skip to content

Commit

Permalink
Create serving certs for headless services on OpenShift (#818)
Browse files Browse the repository at this point in the history
Add annotation to create serving cerfificates for services on OpenShift.

Resolves: #818

Signed-off-by: Robert Kukura <[email protected]>
  • Loading branch information
Robert Kukura committed Apr 18, 2022
1 parent 7cedc89 commit 7fff13b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/collector/reconcile/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ func headless(ctx context.Context, params Params) *corev1.Service {
}

h.Name = naming.HeadlessService(params.Instance)

// copy to avoid modifying params.Instance.Annotations
annotations := map[string]string{
"service.beta.openshift.io/serving-cert-secret-name": fmt.Sprintf("%s-tls", h.Name),
}
for k, v := range h.Annotations {
annotations[k] = v
}
h.Annotations = annotations

h.Spec.ClusterIP = "None"
return h
}
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/reconcile/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func TestDeleteServices(t *testing.T) {
func TestHeadlessService(t *testing.T) {
t.Run("should return headless service", func(t *testing.T) {
actual := headless(context.Background(), params())
assert.Equal(t, actual.Annotations["service.beta.openshift.io/serving-cert-secret-name"], "test-collector-headless-tls")
assert.Equal(t, actual.Spec.ClusterIP, "None")
})
}
Expand Down

0 comments on commit 7fff13b

Please sign in to comment.