Skip to content

Instantly share code, notes, and snippets.

@austincunningham
Created July 4, 2022 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austincunningham/d863603fc5e55517894dc3a183176499 to your computer and use it in GitHub Desktop.
Save austincunningham/d863603fc5e55517894dc3a183176499 to your computer and use it in GitHub Desktop.
// check the WATCH_NAMESPACE env var to see if populated
var watchNamespaceEnvVar = "WATCH_NAMESPACE"
watchNamespace, found := os.LookupEnv(watchNamespaceEnvVar)
if !found {
return "", fmt.Errorf("%s must be set", watchNamespaceEnvVar)
}
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: "f1c5ece8.example.com",
Namespace: watchNamespace, // namespaced-scope when the value is not an empty string
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment