From 4f58f8e966522c3196eec819d46659c5df838109 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Mon, 6 Jul 2020 19:12:32 -0400 Subject: [PATCH] Custom default backend service must have ports --- internal/ingress/controller/controller.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index 59e9b25d157..d8784c898bb 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -644,6 +644,11 @@ func (n *NGINXController) getBackendServers(ingresses []*ingress.Ingress) ([]*in continue } + if len(location.DefaultBackend.Spec.Ports) == 0 { + klog.Errorf("Custom default backend service %v/%v has no ports. Ignoring", location.DefaultBackend.Namespace, location.DefaultBackend.Name) + continue + } + sp := location.DefaultBackend.Spec.Ports[0] endps := getEndpoints(location.DefaultBackend, &sp, apiv1.ProtocolTCP, n.store.GetServiceEndpoints) // custom backend is valid only if contains at least one endpoint