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

Add ability to read port from svc.status.loadbalancer.port #2302

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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