Skip to content

Commit

Permalink
Adding target-allocator label to service selectors (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitali-salvi authored Oct 7, 2024
1 parent b3cf3cf commit 2dc2f2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/manifests/targetallocator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Service(params manifests.Params) *corev1.Service {
labels["app.kubernetes.io/version"] = "latest"
}

selector := Labels(params.OtelCol, naming.TAService())
selector := Labels(params.OtelCol, naming.TargetAllocator(params.OtelCol.Name))

return &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Expand Down
9 changes: 9 additions & 0 deletions internal/manifests/targetallocator/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@ func TestServicePorts(t *testing.T) {

ports := []v1.ServicePort{{Name: "targetallocation", Port: 80, TargetPort: intstr.FromInt32(8080)}}

expectedLabels := map[string]string{
"app.kubernetes.io/managed-by": "amazon-cloudwatch-agent-operator",
"app.kubernetes.io/instance": "default.my-instance",
"app.kubernetes.io/part-of": "amazon-cloudwatch-agent",
"app.kubernetes.io/component": "amazon-cloudwatch-agent-target-allocator",
"app.kubernetes.io/name": "my-instance-target-allocator",
}

s := Service(params)

assert.Equal(t, ports[0].Name, s.Spec.Ports[0].Name)
assert.Equal(t, ports[0].Port, s.Spec.Ports[0].Port)
assert.Equal(t, ports[0].TargetPort, s.Spec.Ports[0].TargetPort)
assert.Equal(t, expectedLabels, s.Spec.Selector)
}

0 comments on commit 2dc2f2b

Please sign in to comment.