@@ -146,6 +146,8 @@ func registerServe(app *kingpin.Application) (*kingpin.CmdClause, *serveContext)
146146 serve .Flag ("envoy-service-https-port" , "Kubernetes Service port for HTTPS requests." ).PlaceHolder ("<port>" ).IntVar (& ctx .httpsPort )
147147 serve .Flag ("envoy-service-name" , "Name of the Envoy service to inspect for Ingress status details." ).PlaceHolder ("<name>" ).StringVar (& ctx .Config .EnvoyServiceName )
148148 serve .Flag ("envoy-service-namespace" , "Envoy Service Namespace." ).PlaceHolder ("<namespace>" ).StringVar (& ctx .Config .EnvoyServiceNamespace )
149+ serve .Flag ("envoy-ingress-name" , "Name of the Envoy ingress to inspect for Ingress status details." ).PlaceHolder ("<name>" ).StringVar (& ctx .Config .EnvoyIngressName )
150+ serve .Flag ("envoy-ingress-namespace" , "Envoy Ingress Namespace." ).PlaceHolder ("<namespace>" ).StringVar (& ctx .Config .EnvoyIngressNamespace )
149151
150152 serve .Flag ("health-address" , "Address the health HTTP endpoint will bind to." ).PlaceHolder ("<ipaddr>" ).StringVar (& ctx .healthAddr )
151153 serve .Flag ("health-port" , "Port the health HTTP endpoint will bind to." ).PlaceHolder ("<port>" ).IntVar (& ctx .healthPort )
@@ -688,6 +690,50 @@ func (s *Server) doServe() error {
688690 return err
689691 }
690692
693+ // Register an informer to watch envoy's service if we haven't been given static details.
694+ if lbAddress := contourConfiguration .Ingress .StatusAddress ; len (lbAddress ) > 0 {
695+ s .log .WithField ("loadbalancer-address" , lbAddress ).Info ("Using supplied information for Ingress status" )
696+ lbsw .lbStatus <- parseStatusFlag (lbAddress )
697+ } else {
698+ serviceHandler := & k8s.ServiceStatusLoadBalancerWatcher {
699+ ServiceName : contourConfiguration .Envoy .Service .Name ,
700+ LBStatus : lbsw .lbStatus ,
701+ Log : s .log .WithField ("context" , "serviceStatusLoadBalancerWatcher" ),
702+ }
703+
704+ var handler cache.ResourceEventHandler = serviceHandler
705+ if contourConfiguration .Envoy .Service .Namespace != "" {
706+ handler = k8s .NewNamespaceFilter ([]string {contourConfiguration .Envoy .Service .Namespace }, handler )
707+ }
708+
709+ if err := s .informOnResource (& corev1.Service {}, handler ); err != nil {
710+ s .log .WithError (err ).WithField ("resource" , "services" ).Fatal ("failed to create informer" )
711+ }
712+
713+ ingressHandler := & k8s.IngressStatusLoadBalancerWatcher {
714+ ServiceName : contourConfiguration .Envoy .Service .Name ,
715+ LBStatus : lbsw .lbStatus ,
716+ Log : s .log .WithField ("context" , "ingressStatusLoadBalancerWatcher" ),
717+ }
718+
719+ var ingressEventHandler cache.ResourceEventHandler = ingressHandler
720+ if contourConfiguration .Envoy .Ingress .Namespace != "" {
721+ handler = k8s .NewNamespaceFilter ([]string {contourConfiguration .Envoy .Ingress .Namespace }, handler )
722+ }
723+
724+ if err := informOnResource (& networking_v1.Ingress {}, ingressEventHandler , s .mgr .GetCache ()); err != nil {
725+ s .log .WithError (err ).WithField ("resource" , "ingresses" ).Fatal ("failed to create ingresses informer" )
726+ }
727+
728+ s .log .WithField ("envoy-service-name" , contourConfiguration .Envoy .Service .Name ).
729+ WithField ("envoy-service-namespace" , contourConfiguration .Envoy .Service .Namespace ).
730+ Info ("Watching Service for Ingress status" )
731+
732+ s .log .WithField ("envoy-ingress-name" , contourConfiguration .Envoy .Ingress .Name ).
733+ WithField ("envoy-ingress-namespace" , contourConfiguration .Envoy .Ingress .Namespace ).
734+ Info ("Watching Ingress for Ingress status" )
735+ }
736+
691737 xdsServer := & xdsServer {
692738 log : s .log ,
693739 registry : s .registry ,
0 commit comments