Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Add ability to read port from svc.status.loadbalancer.port
Browse files Browse the repository at this point in the history
Signed-off-by: Daishan Peng <[email protected]>
  • Loading branch information
StrongMonkey committed Oct 27, 2023
1 parent 8f0e3f1 commit ad35369
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/controller/appstatus/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ func serviceEndpoints(ctx context.Context, c kclient.Client, app *v1.AppInstance

for _, ingress := range service.Status.LoadBalancer.Ingress {
if ingress.Hostname != "" {
portNum := port.Port
if len(ingress.Ports) > 0 {
// not sure when status will have more than one port, but now for just handle one port
portNum = ingress.Ports[0].Port
}
endpoints = append(endpoints, v1.Endpoint{
Target: containerName,
TargetPort: port.TargetPort.IntVal,
Address: fmt.Sprintf("%s:%d", ingress.Hostname, port.Port),
Address: fmt.Sprintf("%s:%d", ingress.Hostname, portNum),
Protocol: protocol,
})
} else if ingress.IP != "" {
Expand Down

0 comments on commit ad35369

Please sign in to comment.