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 1 commit
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
17 changes: 13 additions & 4 deletions backend/src/crd/controller/scheduledworkflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import (
)

var (
masterURL string
kubeconfig string
masterURL string
kubeconfig string
informerNamespace string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please also do it for the viewer CRD so that folks that implement a new CRD have a consistent pattern to follow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicaire Viewer CRD uses another approach (SimpleController) to implement. Not sure how to plugin a namespace into it.. Do you happen to know? @neuromage

)

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 informerNamespace == "" {
scheduleInformerFactory = swfinformers.NewSharedInformerFactory(scheduleClient, time.Second*30)
workflowInformerFactory = workflowinformers.NewSharedInformerFactory(workflowClient, time.Second*30)
} else {
scheduleInformerFactory = swfinformers.NewFilteredSharedInformerFactory(scheduleClient, time.Second*30, informerNamespace, nil)
workflowInformerFactory = workflowinformers.NewFilteredSharedInformerFactory(workflowClient, time.Second*30, informerNamespace, 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(&informerNamespace, "informer-namespace", "", "The namespace name used for Kubernetes informers to obtain the listers.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just namespace is enough? (Same for the other instances)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

}