Add function to allow custom values in Ingress status
This commit is contained in:
parent
c43c3a95b0
commit
addcc4639f
4 changed files with 19 additions and 0 deletions
|
@ -35,6 +35,7 @@ import (
|
||||||
|
|
||||||
proxyproto "github.com/armon/go-proxyproto"
|
proxyproto "github.com/armon/go-proxyproto"
|
||||||
api_v1 "k8s.io/client-go/pkg/api/v1"
|
api_v1 "k8s.io/client-go/pkg/api/v1"
|
||||||
|
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||||
ngx_template "k8s.io/ingress/controllers/nginx/pkg/template"
|
ngx_template "k8s.io/ingress/controllers/nginx/pkg/template"
|
||||||
|
@ -296,6 +297,11 @@ func (n NGINXController) Info() *ingress.BackendInfo {
|
||||||
func (n *NGINXController) ConfigureFlags(flags *pflag.FlagSet) {
|
func (n *NGINXController) ConfigureFlags(flags *pflag.FlagSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateIngressStatus custom Ingress status update
|
||||||
|
func (n *NGINXController) UpdateIngressStatus(*extensions.Ingress) []api_v1.LoadBalancerIngress {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// OverrideFlags customize NGINX controller flags
|
// OverrideFlags customize NGINX controller flags
|
||||||
func (n *NGINXController) OverrideFlags(flags *pflag.FlagSet) {
|
func (n *NGINXController) OverrideFlags(flags *pflag.FlagSet) {
|
||||||
ic, _ := flags.GetString("ingress-class")
|
ic, _ := flags.GetString("ingress-class")
|
||||||
|
|
|
@ -323,6 +323,7 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
IngressClass: config.IngressClass,
|
IngressClass: config.IngressClass,
|
||||||
DefaultIngressClass: config.DefaultIngressClass,
|
DefaultIngressClass: config.DefaultIngressClass,
|
||||||
UpdateStatusOnShutdown: config.UpdateStatusOnShutdown,
|
UpdateStatusOnShutdown: config.UpdateStatusOnShutdown,
|
||||||
|
CustomIngressStatus: ic.cfg.Backend.UpdateIngressStatus,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")
|
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")
|
||||||
|
|
|
@ -62,6 +62,8 @@ type Config struct {
|
||||||
|
|
||||||
DefaultIngressClass string
|
DefaultIngressClass string
|
||||||
IngressClass string
|
IngressClass string
|
||||||
|
|
||||||
|
CustomIngressStatus func(*extensions.Ingress) []api_v1.LoadBalancerIngress
|
||||||
}
|
}
|
||||||
|
|
||||||
// statusSync keeps the status IP in each Ingress rule updated executing a periodic check
|
// 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addrs := s.CustomIngressStatus(currIng)
|
||||||
|
if addrs != nil {
|
||||||
|
newIPs = addrs
|
||||||
|
}
|
||||||
|
|
||||||
curIPs := currIng.Status.LoadBalancer.Ingress
|
curIPs := currIng.Status.LoadBalancer.Ingress
|
||||||
sort.Sort(loadBalancerIngressByIP(curIPs))
|
sort.Sort(loadBalancerIngressByIP(curIPs))
|
||||||
if ingressSliceEqual(newIPs, curIPs) {
|
if ingressSliceEqual(newIPs, curIPs) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apiserver/pkg/server/healthz"
|
"k8s.io/apiserver/pkg/server/healthz"
|
||||||
api "k8s.io/client-go/pkg/api/v1"
|
api "k8s.io/client-go/pkg/api/v1"
|
||||||
|
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||||
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
"k8s.io/ingress/core/pkg/ingress/annotations/auth"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
||||||
|
@ -92,6 +93,10 @@ type Controller interface {
|
||||||
OverrideFlags(*pflag.FlagSet)
|
OverrideFlags(*pflag.FlagSet)
|
||||||
// DefaultIngressClass just return the default ingress class
|
// DefaultIngressClass just return the default ingress class
|
||||||
DefaultIngressClass() string
|
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,
|
// StoreLister returns the configured stores for ingresses, services,
|
||||||
|
|
Loading…
Reference in a new issue