From 45ed5b939f565ca04c5706c03adb22016f74243e Mon Sep 17 00:00:00 2001 From: Michael Pleshakov Date: Thu, 31 Mar 2016 14:58:46 -0700 Subject: [PATCH] Added support to specify a namespace to watch for Ingress resources --- nginx-controller/main.go | 7 ++++++- nginx-plus-controller/main.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nginx-controller/main.go b/nginx-controller/main.go index 7bd86547b2..7abdbc1462 100644 --- a/nginx-controller/main.go +++ b/nginx-controller/main.go @@ -8,6 +8,7 @@ import ( "github.com/nginxinc/kubernetes-ingress/nginx-controller/controller" "github.com/nginxinc/kubernetes-ingress/nginx-controller/nginx" + "k8s.io/kubernetes/pkg/api" client "k8s.io/kubernetes/pkg/client/unversioned" ) @@ -17,6 +18,10 @@ var ( given url and creates a proxy client. Regenerated NGINX configuration files are not written to the disk, instead they are printed to stdout. Also NGINX is not getting invoked. This flag is for testing.`) + + watchNamespace = flag.String("watch-namespace", api.NamespaceAll, + `Namespace to watch for Ingress/Services/Endpoints. By default the controller + watches acrosss all namespaces`) ) func main() { @@ -41,7 +46,7 @@ func main() { resolver := getKubeDNSIP(kubeClient) ngxc, _ := nginx.NewNGINXController(resolver, "/etc/nginx/", local) ngxc.Start() - lbc, _ := controller.NewLoadBalancerController(kubeClient, 30*time.Second, "default", ngxc) + lbc, _ := controller.NewLoadBalancerController(kubeClient, 30*time.Second, *watchNamespace, ngxc) lbc.Run() } diff --git a/nginx-plus-controller/main.go b/nginx-plus-controller/main.go index 003f5347b8..1496170a0a 100644 --- a/nginx-plus-controller/main.go +++ b/nginx-plus-controller/main.go @@ -8,6 +8,7 @@ import ( "github.com/nginxinc/kubernetes-ingress/nginx-plus-controller/controller" "github.com/nginxinc/kubernetes-ingress/nginx-plus-controller/nginx" + "k8s.io/kubernetes/pkg/api" client "k8s.io/kubernetes/pkg/client/unversioned" ) @@ -17,6 +18,10 @@ var ( given url and creates a proxy client. Regenerated NGINX configuration files are not written to the disk, instead they are printed to stdout. Also NGINX is not getting invoked. This flag is for testing.`) + + watchNamespace = flag.String("watch-namespace", api.NamespaceAll, + `Namespace to watch for Ingress/Services/Endpoints. By default the controller + watches acrosss all namespaces`) ) func main() { @@ -41,7 +46,7 @@ func main() { resolver := getKubeDNSIP(kubeClient) ngxc, _ := nginx.NewNGINXController(resolver, "/etc/nginx/", local) ngxc.Start() - lbc, _ := controller.NewLoadBalancerController(kubeClient, 30*time.Second, "default", ngxc) + lbc, _ := controller.NewLoadBalancerController(kubeClient, 30*time.Second, *watchNamespace, ngxc) lbc.Run() }