Add function to allow custom values in Ingress status
This commit is contained in:
parent
c43c3a95b0
commit
4ac1990912
4 changed files with 21 additions and 2 deletions
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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)")
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue