diff --git a/internal/configs/ingress.go b/internal/configs/ingress.go index e19bd37d83..ff09975fba 100644 --- a/internal/configs/ingress.go +++ b/internal/configs/ingress.go @@ -512,8 +512,9 @@ func createUpstream(ingEx *IngressEx, name string, backend *networking.IngressBa } if cfg.UseClusterIP { + fqdn := fmt.Sprintf("%s.%s.svc.cluster.local:%d", backend.Service.Name, ingEx.Ingress.Namespace, backend.Service.Port.Number) upsServers = append(upsServers, version1.UpstreamServer{ - Address: fmt.Sprintf("%s:%d", backend.Service.Name, backend.Service.Port.Number), + Address: fqdn, MaxFails: cfg.MaxFails, MaxConns: cfg.MaxConns, FailTimeout: cfg.FailTimeout, diff --git a/internal/configs/ingress_test.go b/internal/configs/ingress_test.go index ea68e6cb5b..decf9f4a2f 100644 --- a/internal/configs/ingress_test.go +++ b/internal/configs/ingress_test.go @@ -700,7 +700,7 @@ func createExpectedConfigForMergeableCafeIngressWithUseClusterIP() version1.Ingr UpstreamZoneSize: upstreamZoneSize, UpstreamServers: []version1.UpstreamServer{ { - Address: "coffee-svc:80", + Address: "coffee-svc.default.svc.cluster.local:80", MaxFails: 1, MaxConns: 0, FailTimeout: "10s", @@ -803,7 +803,7 @@ func createExpectedConfigForCafeIngressWithUseClusterIP() version1.IngressNginxC UpstreamZoneSize: upstreamZoneSize, UpstreamServers: []version1.UpstreamServer{ { - Address: "coffee-svc:80", + Address: "coffee-svc.default.svc.cluster.local:80", MaxFails: 1, MaxConns: 0, FailTimeout: "10s", @@ -817,7 +817,7 @@ func createExpectedConfigForCafeIngressWithUseClusterIP() version1.IngressNginxC UpstreamZoneSize: upstreamZoneSize, UpstreamServers: []version1.UpstreamServer{ { - Address: "tea-svc:80", + Address: "tea-svc.default.svc.cluster.local:80", MaxFails: 1, MaxConns: 0, FailTimeout: "10s",