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

Add support for passing namespace using manager cmdline flag #405

Closed
Closed
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
14 changes: 12 additions & 2 deletions pkg/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
)

var (
kubeconfig, apiServerURL string
log = logf.RuntimeLog.WithName("client").WithName("config")
kubeconfig, apiServerURL, namespace string
log = logf.RuntimeLog.WithName("client").WithName("config")
)

func init() {
Expand All @@ -42,6 +42,10 @@ func init() {
flag.StringVar(&apiServerURL, "master", "",
"(Deprecated: switch to `--kubeconfig`) The address of the Kubernetes API server. Overrides any value in kubeconfig. "+
"Only required if out-of-cluster.")

flag.StringVar(&namespace, "namespace", "",
"Namespace if specified restricts the manager's cache to watch objects in the desired namespace. "+
"Otherwise objects will be watched in all the namespaces.")
}

// GetConfig creates a *rest.Config for talking to a Kubernetes API server.
Expand Down Expand Up @@ -112,3 +116,9 @@ func GetConfigOrDie() *rest.Config {
}
return config
}

// GetNamespaceConfig returns the name of the namespace which is used to restrict
// the manager's cache to watch objects in this namespace
func GetNamespaceConfig() string {
return namespace
}