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

Commit

Permalink
Merge pull request #2302 from StrongMonkey/read-servicelb-port
Browse files Browse the repository at this point in the history
Add ability to read port from svc.status.loadbalancer.port
  • Loading branch information
StrongMonkey authored Nov 2, 2023
2 parents a732221 + 6efdcfd commit 7547021
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pkg/controller/appstatus/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7547021

Please sign in to comment.