Skip to content

Commit

Permalink
Expose admin ports for agent, collector, and query Deployments via th…
Browse files Browse the repository at this point in the history
…e equivalent Service (jaegertracing#2262)

* Expose admin port via Service

Signed-off-by: Thomas Paulin <[email protected]>

* Check for named admin port too

Signed-off-by: Thomas <[email protected]>

* Check target ports

Signed-off-by: Thomas <[email protected]>

* fix test

Signed-off-by: Benedikt Bongartz <[email protected]>

* add missing port to istio e2e test

Signed-off-by: Benedikt Bongartz <[email protected]>

---------

Signed-off-by: Thomas Paulin <[email protected]>
Signed-off-by: Thomas <[email protected]>
Signed-off-by: Benedikt Bongartz <[email protected]>
Co-authored-by: Thomas Paulin <[email protected]>
  • Loading branch information
frzifus and thomaspaulin authored Jul 12, 2023
1 parent d76d8cd commit 0ca7049
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 10 deletions.
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

0 comments on commit 0ca7049

Please sign in to comment.