From 3d31c6b718e0b9a7ecb6aa7c78e1c5c7eea397fb Mon Sep 17 00:00:00 2001 From: Tom Plant Date: Sat, 16 Dec 2023 19:46:27 +1100 Subject: [PATCH] feat: set arbitrary service hostname via annotation Fixes #14 --- source/service.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/service.go b/source/service.go index a0fbc5d..e82e94d 100644 --- a/source/service.go +++ b/source/service.go @@ -92,8 +92,14 @@ func (s *ServiceSource) buildRecord(obj interface{}, action string) (resource.Re return advertiseObj, nil } - advertiseObj.Name = service.Name advertiseObj.Namespace = service.Namespace + + if hostname, ok := service.Annotations["external-mdns.blakecovarrubias.com/hostname"]; ok { + advertiseObj.Name = hostname + } else { + advertiseObj.Name = service.Name + } + advertiseObj.IPs = []string{} if service.Spec.Type == "ClusterIP" && s.publishInternal {