From 6efdcfd56c69288f60115a2a9e74856763cb1d48 Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Fri, 27 Oct 2023 10:57:52 -0700 Subject: [PATCH] Add ability to read port from svc.status.loadbalancer.port Signed-off-by: Daishan Peng --- pkg/controller/appstatus/endpoints.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkg/controller/appstatus/endpoints.go b/pkg/controller/appstatus/endpoints.go index 43edf4142..c1a68b584 100644 --- a/pkg/controller/appstatus/endpoints.go +++ b/pkg/controller/appstatus/endpoints.go @@ -50,12 +50,24 @@ func serviceEndpoints(ctx context.Context, c kclient.Client, app *v1.AppInstance for _, ingress := range service.Status.LoadBalancer.Ingress { if ingress.Hostname != "" { - endpoints = append(endpoints, v1.Endpoint{ - Target: containerName, - TargetPort: port.TargetPort.IntVal, - Address: fmt.Sprintf("%s:%d", ingress.Hostname, port.Port), - Protocol: protocol, - }) + portNum := port.Port + if len(ingress.Ports) > 0 { + for _, ingressPort := range ingress.Ports { + endpoints = append(endpoints, v1.Endpoint{ + Target: containerName, + TargetPort: port.TargetPort.IntVal, + Address: fmt.Sprintf("%s:%d", ingress.Hostname, ingressPort.Port), + Protocol: protocol, + }) + } + } else { + endpoints = append(endpoints, v1.Endpoint{ + Target: containerName, + TargetPort: port.TargetPort.IntVal, + Address: fmt.Sprintf("%s:%d", ingress.Hostname, portNum), + Protocol: protocol, + }) + } } else if ingress.IP != "" { endpoints = append(endpoints, v1.Endpoint{ Target: containerName,