Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions source/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ func endpointsFromIngress(ing *networkv1.Ingress, ignoreHostnameAnnotation bool,
return endpoints
}

// targetsFromIngressStatus extracts targets from ingress load balancer status.
// Both IP and Hostname can be set simultaneously (Kubernetes API does not enforce
// mutual exclusivity), so we collect both when present.
func targetsFromIngressStatus(status networkv1.IngressStatus) endpoint.Targets {
var targets endpoint.Targets

Expand Down
37 changes: 37 additions & 0 deletions source/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,43 @@ func TestIngressWithConfiguration(t *testing.T) {
},
},
},
{
title: "no annotations, multiple ingresses, mixed IP and Hostname targets",
ingresses: []*networkv1.Ingress{
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-ingress",
Namespace: "default",
},
Spec: networkv1.IngressSpec{
IngressClassName: testutils.ToPtr("alb"),
Rules: []networkv1.IngressRule{
{Host: "app.example.com"},
},
},
Status: networkv1.IngressStatus{
LoadBalancer: networkv1.IngressLoadBalancerStatus{
Ingress: []networkv1.IngressLoadBalancerIngress{
{IP: "1.2.3.4"},
{Hostname: "foo.tld"},
},
},
},
},
},
expected: []*endpoint.Endpoint{
{
DNSName: "app.example.com",
RecordType: endpoint.RecordTypeA,
Targets: endpoint.Targets{"1.2.3.4"},
},
{
DNSName: "app.example.com",
RecordType: endpoint.RecordTypeCNAME,
Targets: endpoint.Targets{"foo.tld"},
},
},
},
} {
t.Run(tt.title, func(t *testing.T) {
kubeClient := fake.NewClientset()
Expand Down
Loading