Skip to content

Commit

Permalink
Add TCP port to Lighthouse CoreDNS ClusterIP service
Browse files Browse the repository at this point in the history
Define TCP port in ClusterIP service to allow k8s DNS server to forward TCP connection requests.
Lighthouse CoreDNS pods already support TCP on port 53.
This is needed to support TCP retries after truncation per RFC1035 and RFC2181.

Signed-off-by: Tony Le <[email protected]>
  • Loading branch information
t0lya committed Sep 11, 2024
1 parent ab6aed4 commit 9a37cd1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
27 changes: 19 additions & 8 deletions controllers/servicediscovery/servicediscovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,26 @@ func newLighthouseCoreDNSService(cr *submarinerv1alpha1.ServiceDiscovery) *corev
Labels: labels,
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Name: "udp",
Protocol: "UDP",
Port: 53,
TargetPort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 53,
Ports: []corev1.ServicePort{
{
Name: "udp",
Protocol: "UDP",
Port: 53,
TargetPort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 53,
},
},
{
Name: "tcp",
Protocol: "TCP",
Port: 53,
TargetPort: intstr.IntOrString{
Type: intstr.Int,
IntVal: 53,
},
},
}},
},
Type: corev1.ServiceTypeClusterIP,
Selector: map[string]string{
"app": names.LighthouseCoreDNSComponent,
Expand Down
5 changes: 4 additions & 1 deletion controllers/servicediscovery/servicediscovery_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,13 @@ func (t *testDriver) assertLighthouseCoreDNSService(ctx context.Context) *corev1
service)).To(Succeed())

Expect(service.Labels).To(HaveKeyWithValue("app", lighthouseDNSServiceName))
Expect(service.Spec.Ports).To(HaveLen(1))
Expect(service.Spec.Ports).To(HaveLen(2))
Expect(service.Spec.Ports[0].Protocol).To(Equal(corev1.Protocol("UDP")))
Expect(service.Spec.Ports[0].Port).To(Equal(int32(53)))
Expect(service.Spec.Ports[0].TargetPort.IntVal).To(Equal(int32(53)))
Expect(service.Spec.Ports[1].Protocol).To(Equal(corev1.Protocol("TCP")))
Expect(service.Spec.Ports[1].Port).To(Equal(int32(53)))
Expect(service.Spec.Ports[1].TargetPort.IntVal).To(Equal(int32(53)))

return service
}
Expand Down

0 comments on commit 9a37cd1

Please sign in to comment.