Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to specify namespace for Kubernetes informers #851

Merged
merged 2 commits into from
Feb 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.")
}