Skip to content

Commit

Permalink
Allow users to specify namespace for Kubernetes informers (kubeflow#851)
Browse files Browse the repository at this point in the history
* Allow users to specify namespace for Kubernetes informers

* Change variable informerNamespace to namespace
  • Loading branch information
ywskycn authored and k8s-ci-robot committed Feb 28, 2019
1 parent ef93365 commit a350a85
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions backend/src/crd/controller/scheduledworkflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
var (
masterURL string
kubeconfig string
namespace string
)

func main() {
Expand Down Expand Up @@ -61,8 +62,15 @@ func main() {
log.Fatalf("Error building workflow clientset: %s", err.Error())
}

scheduleInformerFactory := swfinformers.NewSharedInformerFactory(scheduleClient, time.Second*30)
workflowInformerFactory := workflowinformers.NewSharedInformerFactory(workflowClient, time.Second*30)
var scheduleInformerFactory swfinformers.SharedInformerFactory
var workflowInformerFactory workflowinformers.SharedInformerFactory
if namespace == "" {
scheduleInformerFactory = swfinformers.NewSharedInformerFactory(scheduleClient, time.Second*30)
workflowInformerFactory = workflowinformers.NewSharedInformerFactory(workflowClient, time.Second*30)
} else {
scheduleInformerFactory = swfinformers.NewFilteredSharedInformerFactory(scheduleClient, time.Second*30, namespace, nil)
workflowInformerFactory = workflowinformers.NewFilteredSharedInformerFactory(workflowClient, time.Second*30, namespace, nil)
}

controller := NewController(
kubeClient,
Expand All @@ -83,4 +91,5 @@ func main() {
func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&namespace, "namespace", "", "The namespace name used for Kubernetes informers to obtain the listers.")
}

0 comments on commit a350a85

Please sign in to comment.