diff --git a/cmd/controller/app/controller.go b/cmd/controller/app/controller.go index aad96e829..14f6c2d01 100644 --- a/cmd/controller/app/controller.go +++ b/cmd/controller/app/controller.go @@ -28,7 +28,11 @@ import ( kubeinformers "k8s.io/client-go/informers" ) -const controllerAgentName = "cert-manager-controller" +const ( + controllerAgentName = "cert-manager-controller" + + defaultNamespace = "" +) func Run(opts *options.ControllerOptions, stopCh <-chan struct{}) { ctx, kubeCfg, err := buildControllerContext(opts) @@ -120,8 +124,8 @@ func buildControllerContext(opts *options.ControllerOptions) (*controller.Contex // If it is specified, all operations relating to ClusterIssuer resources // should be disabled and thus we don't need to also create factories for // the --cluster-resource-namespace. - sharedInformerFactory := informers.NewFilteredSharedInformerFactory(intcl, time.Second*30, opts.Namespace, nil) - kubeSharedInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(cl, time.Second*30, opts.Namespace, nil) + sharedInformerFactory := informers.NewFilteredSharedInformerFactory(intcl, time.Second*30, defaultNamespace, nil) + kubeSharedInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(cl, time.Second*30, defaultNamespace, nil) return &controller.Context{ Client: cl, CMClient: intcl, @@ -134,13 +138,13 @@ func buildControllerContext(opts *options.ControllerOptions) (*controller.Contex Recorder: recorder, KubeSharedInformerFactory: kubeSharedInformerFactory, SharedInformerFactory: sharedInformerFactory, - Namespace: opts.Namespace, + Namespace: defaultNamespace, ClusterResourceNamespace: opts.ClusterResourceNamespace, ACMEHTTP01SolverImage: opts.ACMEHTTP01SolverImage, ClusterIssuerAmbientCredentials: opts.ClusterIssuerAmbientCredentials, IssuerAmbientCredentials: opts.IssuerAmbientCredentials, }), - Namespace: opts.Namespace, + Namespace: defaultNamespace, ClusterResourceNamespace: opts.ClusterResourceNamespace, }, kubeCfg, nil } diff --git a/cmd/controller/app/options/options.go b/cmd/controller/app/options/options.go index eabf792bf..8c37d5163 100644 --- a/cmd/controller/app/options/options.go +++ b/cmd/controller/app/options/options.go @@ -11,7 +11,6 @@ import ( type ControllerOptions struct { APIServerHost string - Namespace string ClusterResourceNamespace string LeaderElect bool @@ -28,7 +27,6 @@ type ControllerOptions struct { const ( defaultAPIServerHost = "" - defaultNamespace = "" defaultClusterResourceNamespace = "kube-system" defaultLeaderElect = true @@ -48,7 +46,6 @@ var ( func NewControllerOptions() *ControllerOptions { return &ControllerOptions{ APIServerHost: defaultAPIServerHost, - Namespace: defaultNamespace, ClusterResourceNamespace: defaultClusterResourceNamespace, LeaderElect: defaultLeaderElect, LeaderElectionNamespace: defaultLeaderElectionNamespace, @@ -64,13 +61,9 @@ func (s *ControllerOptions) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.APIServerHost, "master", defaultAPIServerHost, ""+ "Optional apiserver host address to connect to. If not specified, autoconfiguration "+ "will be attempted.") - fs.StringVar(&s.Namespace, "namespace", defaultNamespace, ""+ - "Optional namespace to monitor resources within. This can be used to limit the scope "+ - "of cert-manager to a single namespace. If not specified, all namespaces will be watched") fs.StringVar(&s.ClusterResourceNamespace, "cluster-resource-namespace", defaultClusterResourceNamespace, ""+ "Namespace to store resources owned by cluster scoped resources such as ClusterIssuer in. "+ "This must be specified if ClusterIssuers are enabled.") - fs.BoolVar(&s.LeaderElect, "leader-elect", true, ""+ "If true, cert-manager will perform leader election between instances to ensure no more "+ "than one instance of cert-manager operates at a time")