diff --git a/controllers/nginx/pkg/cmd/controller/nginx.go b/controllers/nginx/pkg/cmd/controller/nginx.go index 979b25f23..84ed13813 100644 --- a/controllers/nginx/pkg/cmd/controller/nginx.go +++ b/controllers/nginx/pkg/cmd/controller/nginx.go @@ -34,7 +34,8 @@ import ( "github.com/spf13/pflag" proxyproto "github.com/armon/go-proxyproto" - api_v1 "k8s.io/client-go/pkg/api/v1" + api_v1 "k8s.io/api/core/v1" + "k8s.io/client-go/pkg/apis/extensions" "k8s.io/ingress/controllers/nginx/pkg/config" ngx_template "k8s.io/ingress/controllers/nginx/pkg/template" @@ -373,6 +374,11 @@ func (n *NGINXController) SetListers(lister ingress.StoreLister) { n.storeLister = lister } +// UpdateIngressStatus custom Ingress status update +func (n *NGINXController) UpdateIngressStatus(*extensions.Ingress) []api_v1.LoadBalancerIngress { + return nil +} + // OnUpdate is called by syncQueue in https://github.com/aledbf/ingress-controller/blob/master/pkg/ingress/controller/controller.go#L82 // periodically to keep the configuration in sync. // diff --git a/core/pkg/ingress/controller/controller.go b/core/pkg/ingress/controller/controller.go index 0453325c9..165d78957 100644 --- a/core/pkg/ingress/controller/controller.go +++ b/core/pkg/ingress/controller/controller.go @@ -323,6 +323,7 @@ func newIngressController(config *Configuration) *GenericController { IngressClass: config.IngressClass, DefaultIngressClass: config.DefaultIngressClass, UpdateStatusOnShutdown: config.UpdateStatusOnShutdown, + CustomIngressStatus: ic.cfg.Backend.UpdateIngressStatus, }) } else { glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)") diff --git a/core/pkg/ingress/status/status.go b/core/pkg/ingress/status/status.go index be59818a1..19a3d0e9e 100644 --- a/core/pkg/ingress/status/status.go +++ b/core/pkg/ingress/status/status.go @@ -62,6 +62,8 @@ type Config struct { DefaultIngressClass string IngressClass string + + CustomIngressStatus func(*extensions.Ingress) []api_v1.LoadBalancerIngress } // statusSync keeps the status IP in each Ingress rule updated executing a periodic check @@ -300,6 +302,11 @@ func (s *statusSync) updateStatus(newIPs []api_v1.LoadBalancerIngress) { return } + addrs := s.CustomIngressStatus(currIng) + if addrs != nil { + newIPs = addrs + } + curIPs := currIng.Status.LoadBalancer.Ingress sort.Sort(loadBalancerIngressByIP(curIPs)) if ingressSliceEqual(newIPs, curIPs) { diff --git a/core/pkg/ingress/types.go b/core/pkg/ingress/types.go index 163286003..642bfc1c1 100644 --- a/core/pkg/ingress/types.go +++ b/core/pkg/ingress/types.go @@ -21,9 +21,10 @@ import ( "github.com/spf13/pflag" + api "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apiserver/pkg/server/healthz" - api "k8s.io/client-go/pkg/api/v1" + "k8s.io/client-go/pkg/apis/extensions" "k8s.io/ingress/core/pkg/ingress/annotations/auth" "k8s.io/ingress/core/pkg/ingress/annotations/authreq" @@ -92,6 +93,10 @@ type Controller interface { OverrideFlags(*pflag.FlagSet) // DefaultIngressClass just return the default ingress class DefaultIngressClass() string + // UpdateIngressStatus custom callback used to update the status in an Ingress rule + // This allows custom implementations + // If the function returns nil the standard functions will be executed. + UpdateIngressStatus(*extensions.Ingress) []api.LoadBalancerIngress } // StoreLister returns the configured stores for ingresses, services,