Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose admin ports for agent, collector, and query Deployments via the equivalent Service #2262

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/service/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ func NewAgentService(jaeger *v1.Jaeger, selector map[string]string) *corev1.Serv
trueVar := true
name := util.DNSName(util.Truncate("%s-agent", 63, jaeger.Name))

args := jaeger.Spec.Agent.Options.ToArgs()

adminPort := util.GetAdminPort(args, 14271)

return &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
Expand Down Expand Up @@ -55,6 +59,10 @@ func NewAgentService(jaeger *v1.Jaeger, selector map[string]string) *corev1.Serv
Port: 6832,
Protocol: corev1.ProtocolUDP,
},
{
Name: "admin-http",
Port: adminPort,
},
},
},
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/service/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ func TestAgentServiceNameAndPorts(t *testing.T) {
assert.Equal(t, "testagentservicenameandports-agent", svc.ObjectMeta.Name)

ports := map[int32]bool{
5775: false,
5778: false,
6831: false,
6832: false,
5775: false,
5778: false,
6831: false,
6832: false,
14271: false,
}

for _, port := range svc.Spec.Ports {
Expand Down
8 changes: 8 additions & 0 deletions pkg/service/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func clusteripCollectorService(jaeger *v1.Jaeger, selector map[string]string) *c

func collectorService(jaeger *v1.Jaeger, selector map[string]string) *corev1.Service {
trueVar := true

args := jaeger.Spec.Collector.Options.ToArgs()
adminPort := util.GetAdminPort(args, 14269)

ports := []corev1.ServicePort{
{
Name: "http-zipkin",
Expand All @@ -56,6 +60,10 @@ func collectorService(jaeger *v1.Jaeger, selector map[string]string) *corev1.Ser
Name: "http-c-binary-trft",
Port: 14268,
},
{
Name: "admin-http",
Port: adminPort,
},
}

ports = append(ports, getOTLPServicePorts(jaeger)...)
Expand Down
1 change: 1 addition & 0 deletions pkg/service/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestCollectorServiceNameAndPorts(t *testing.T) {
14250: false,
14267: false,
14268: false,
14269: false,
}

svc := svcs[0]
Expand Down
9 changes: 9 additions & 0 deletions pkg/service/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func NewQueryService(jaeger *v1.Jaeger, selector map[string]string) *corev1.Serv
annotations["service.alpha.openshift.io/serving-cert-secret-name"] = GetTLSSecretNameForQueryService(jaeger)
}

args := jaeger.Spec.Query.Options.ToArgs()

adminPort := util.GetAdminPort(args, 16687)

ports := []corev1.ServicePort{
{
Name: GetPortNameForQueryService(jaeger),
Expand All @@ -32,6 +36,11 @@ func NewQueryService(jaeger *v1.Jaeger, selector map[string]string) *corev1.Serv
Port: int32(16685),
TargetPort: intstr.FromInt(16685),
},
{
Name: "admin-http",
Port: int32(adminPort),
TargetPort: intstr.FromInt(int(adminPort)),
},
}
if jaeger.Spec.Query.ServiceType == corev1.ServiceTypeNodePort {
ports[0].NodePort = GetNodePortForQueryService(jaeger)
Expand Down
33 changes: 27 additions & 6 deletions pkg/service/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ func TestQueryServiceNameAndPorts(t *testing.T) {
svc := NewQueryService(jaeger, selector)

assert.Equal(t, "testqueryservicenameandports-query", svc.ObjectMeta.Name)
assert.Len(t, svc.Spec.Ports, 2)
assert.Len(t, svc.Spec.Ports, 3)
assert.Equal(t, int32(16686), svc.Spec.Ports[0].Port)
assert.Equal(t, int32(16685), svc.Spec.Ports[1].Port)
assert.Equal(t, int32(16687), svc.Spec.Ports[2].Port)
assert.Equal(t, "http-query", svc.Spec.Ports[0].Name)
assert.Equal(t, "grpc-query", svc.Spec.Ports[1].Name)
assert.Equal(t, "admin-http", svc.Spec.Ports[2].Name)
assert.Equal(t, intstr.FromInt(16686), svc.Spec.Ports[0].TargetPort)
assert.Equal(t, intstr.FromInt(16685), svc.Spec.Ports[1].TargetPort)
assert.Equal(t, intstr.FromInt(16687), svc.Spec.Ports[2].TargetPort)
assert.Len(t, svc.Spec.ClusterIP, 0) // make sure we get a cluster IP
assert.Equal(t, svc.Spec.Type, corev1.ServiceTypeClusterIP) // make sure we get a ClusterIP service
}
Expand All @@ -50,7 +53,7 @@ func TestQueryServiceNameAndPortsWithOAuthProxy(t *testing.T) {
svc := NewQueryService(jaeger, selector)

assert.Equal(t, "testqueryservicenameandportswithoauthproxy-query", svc.ObjectMeta.Name)
assert.Len(t, svc.Spec.Ports, 2)
assert.Len(t, svc.Spec.Ports, 3)
assert.Equal(t, int32(443), svc.Spec.Ports[0].Port)
assert.Equal(t, int32(16685), svc.Spec.Ports[1].Port)
assert.Equal(t, "https-query", svc.Spec.Ports[0].Name)
Expand All @@ -66,13 +69,18 @@ func TestQueryServiceNodePortWithIngress(t *testing.T) {
svc := NewQueryService(jaeger, selector)

assert.Equal(t, "testqueryservicenodeportwithingress-query", svc.ObjectMeta.Name)
assert.Len(t, svc.Spec.Ports, 2)
assert.Len(t, svc.Spec.Ports, 3)
assert.Equal(t, int32(16686), svc.Spec.Ports[0].Port)
assert.Equal(t, int32(16685), svc.Spec.Ports[1].Port)
assert.Equal(t, int32(16687), svc.Spec.Ports[2].Port)
assert.Equal(t, "http-query", svc.Spec.Ports[0].Name)
assert.Equal(t, "grpc-query", svc.Spec.Ports[1].Name)
assert.Equal(t, "admin-http", svc.Spec.Ports[2].Name)
assert.Equal(t, int32(0), svc.Spec.Ports[0].NodePort)
assert.Equal(t, int32(0), svc.Spec.Ports[1].NodePort)
assert.Equal(t, intstr.FromInt(16686), svc.Spec.Ports[0].TargetPort)
assert.Equal(t, intstr.FromInt(16685), svc.Spec.Ports[1].TargetPort)
assert.Equal(t, intstr.FromInt(16687), svc.Spec.Ports[2].TargetPort)
assert.Equal(t, svc.Spec.Type, corev1.ServiceTypeNodePort) // make sure we get a NodePort service
}

Expand All @@ -85,13 +93,16 @@ func TestQueryServiceLoadBalancerWithIngress(t *testing.T) {
svc := NewQueryService(jaeger, selector)

assert.Equal(t, "testqueryservicenodeportwithingress-query", svc.ObjectMeta.Name)
assert.Len(t, svc.Spec.Ports, 2)
assert.Len(t, svc.Spec.Ports, 3)
assert.Equal(t, int32(16686), svc.Spec.Ports[0].Port)
assert.Equal(t, int32(16685), svc.Spec.Ports[1].Port)
assert.Equal(t, int32(16687), svc.Spec.Ports[2].Port)
assert.Equal(t, "http-query", svc.Spec.Ports[0].Name)
assert.Equal(t, "grpc-query", svc.Spec.Ports[1].Name)
assert.Equal(t, "admin-http", svc.Spec.Ports[2].Name)
assert.Equal(t, intstr.FromInt(16686), svc.Spec.Ports[0].TargetPort)
assert.Equal(t, intstr.FromInt(16685), svc.Spec.Ports[1].TargetPort)
assert.Equal(t, intstr.FromInt(16687), svc.Spec.Ports[2].TargetPort)
assert.Equal(t, svc.Spec.Type, corev1.ServiceTypeLoadBalancer) // make sure we get a LoadBalancer service
}

Expand All @@ -105,12 +116,17 @@ func TestQueryServiceSpecifiedNodePortWithIngress(t *testing.T) {
svc := NewQueryService(jaeger, selector)

assert.Equal(t, "testqueryservicespecifiednodeportwithingress-query", svc.ObjectMeta.Name)
assert.Len(t, svc.Spec.Ports, 2)
assert.Len(t, svc.Spec.Ports, 3)
assert.Equal(t, int32(16686), svc.Spec.Ports[0].Port)
assert.Equal(t, int32(16685), svc.Spec.Ports[1].Port)
assert.Equal(t, int32(16687), svc.Spec.Ports[2].Port)
assert.Equal(t, "http-query", svc.Spec.Ports[0].Name)
assert.Equal(t, "grpc-query", svc.Spec.Ports[1].Name)
assert.Equal(t, "admin-http", svc.Spec.Ports[2].Name)
assert.Equal(t, int32(32767), svc.Spec.Ports[0].NodePort) // make sure we get the same NodePort as set above
assert.Equal(t, intstr.FromInt(16686), svc.Spec.Ports[0].TargetPort)
assert.Equal(t, intstr.FromInt(16685), svc.Spec.Ports[1].TargetPort)
assert.Equal(t, intstr.FromInt(16687), svc.Spec.Ports[2].TargetPort)
assert.Equal(t, svc.Spec.Type, corev1.ServiceTypeNodePort)
}

Expand All @@ -123,10 +139,15 @@ func TestQueryServiceSpecAnnotations(t *testing.T) {
svc := NewQueryService(jaeger, selector)

assert.Equal(t, "testqueryservicespecannotations-query", svc.ObjectMeta.Name)
assert.Len(t, svc.Spec.Ports, 2)
assert.Len(t, svc.Spec.Ports, 3)
assert.Equal(t, int32(16686), svc.Spec.Ports[0].Port)
assert.Equal(t, int32(16685), svc.Spec.Ports[1].Port)
assert.Equal(t, int32(16687), svc.Spec.Ports[2].Port)
assert.Equal(t, "http-query", svc.Spec.Ports[0].Name)
assert.Equal(t, "grpc-query", svc.Spec.Ports[1].Name)
assert.Equal(t, "admin-http", svc.Spec.Ports[2].Name)
assert.Equal(t, intstr.FromInt(16686), svc.Spec.Ports[0].TargetPort)
assert.Equal(t, intstr.FromInt(16685), svc.Spec.Ports[1].TargetPort)
assert.Equal(t, intstr.FromInt(16687), svc.Spec.Ports[2].TargetPort)
assert.Equal(t, map[string]string{"component": "jaeger"}, svc.Annotations)
}
8 changes: 8 additions & 0 deletions tests/e2e/miscellaneous/istio/03-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ spec:
port: 14268
protocol: TCP
targetPort: 14268
- name: admin-http
port: 14269
protocol: TCP
targetPort: 14269
- name: grpc-otlp
port: 4317
protocol: TCP
Expand Down Expand Up @@ -61,6 +65,10 @@ spec:
port: 14268
protocol: TCP
targetPort: 14268
- name: admin-http
port: 14269
protocol: TCP
targetPort: 14269
- name: grpc-otlp
port: 4317
protocol: TCP
Expand Down