Remove namespace from more places
This commit is contained in:
parent
1dece103d3
commit
0961e24174
@ -22,7 +22,6 @@ import (
|
|||||||
intscheme "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/scheme"
|
intscheme "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/scheme"
|
||||||
informers "github.com/jetstack/cert-manager/pkg/client/informers/externalversions"
|
informers "github.com/jetstack/cert-manager/pkg/client/informers/externalversions"
|
||||||
"github.com/jetstack/cert-manager/pkg/controller"
|
"github.com/jetstack/cert-manager/pkg/controller"
|
||||||
"github.com/jetstack/cert-manager/pkg/controller/clusterissuers"
|
|
||||||
"github.com/jetstack/cert-manager/pkg/issuer"
|
"github.com/jetstack/cert-manager/pkg/issuer"
|
||||||
"github.com/jetstack/cert-manager/pkg/util/kube"
|
"github.com/jetstack/cert-manager/pkg/util/kube"
|
||||||
kubeinformers "k8s.io/client-go/informers"
|
kubeinformers "k8s.io/client-go/informers"
|
||||||
@ -43,15 +42,7 @@ func Run(opts *options.ControllerOptions, stopCh <-chan struct{}) {
|
|||||||
|
|
||||||
run := func(_ <-chan struct{}) {
|
run := func(_ <-chan struct{}) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
var controllers = make(map[string]controller.Interface)
|
|
||||||
for n, fn := range controller.Known() {
|
for n, fn := range controller.Known() {
|
||||||
if ctx.Namespace != "" && n == clusterissuers.ControllerName {
|
|
||||||
glog.Infof("Skipping ClusterIssuer controller as cert-manager is scoped to a single namespace")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
controllers[n] = fn(ctx)
|
|
||||||
}
|
|
||||||
for n, fn := range controllers {
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(n string, fn controller.Interface) {
|
go func(n string, fn controller.Interface) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
@ -62,7 +53,7 @@ func Run(opts *options.ControllerOptions, stopCh <-chan struct{}) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("error running %s controller: %s", n, err.Error())
|
glog.Fatalf("error running %s controller: %s", n, err.Error())
|
||||||
}
|
}
|
||||||
}(n, fn)
|
}(n, fn(ctx))
|
||||||
}
|
}
|
||||||
glog.V(4).Infof("Starting shared informer factory")
|
glog.V(4).Infof("Starting shared informer factory")
|
||||||
ctx.SharedInformerFactory.Start(stopCh)
|
ctx.SharedInformerFactory.Start(stopCh)
|
||||||
@ -118,12 +109,6 @@ func buildControllerContext(opts *options.ControllerOptions) (*controller.Contex
|
|||||||
eventBroadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: cl.CoreV1().Events("")})
|
eventBroadcaster.StartRecordingToSink(&corev1.EventSinkImpl{Interface: cl.CoreV1().Events("")})
|
||||||
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: controllerAgentName})
|
recorder := eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: controllerAgentName})
|
||||||
|
|
||||||
// We only create SharedInformerFactories for the --namespace specified to
|
|
||||||
// watch. If this namespace is blank (i.e. the default, watch all
|
|
||||||
// namespaces) then the factories will watch all namespaces.
|
|
||||||
// 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.NewSharedInformerFactory(intcl, time.Second*30)
|
sharedInformerFactory := informers.NewSharedInformerFactory(intcl, time.Second*30)
|
||||||
kubeSharedInformerFactory := kubeinformers.NewSharedInformerFactory(cl, time.Second*30)
|
kubeSharedInformerFactory := kubeinformers.NewSharedInformerFactory(cl, time.Second*30)
|
||||||
return &controller.Context{
|
return &controller.Context{
|
||||||
@ -138,13 +123,11 @@ func buildControllerContext(opts *options.ControllerOptions) (*controller.Contex
|
|||||||
Recorder: recorder,
|
Recorder: recorder,
|
||||||
KubeSharedInformerFactory: kubeSharedInformerFactory,
|
KubeSharedInformerFactory: kubeSharedInformerFactory,
|
||||||
SharedInformerFactory: sharedInformerFactory,
|
SharedInformerFactory: sharedInformerFactory,
|
||||||
Namespace: defaultNamespace,
|
|
||||||
ClusterResourceNamespace: opts.ClusterResourceNamespace,
|
ClusterResourceNamespace: opts.ClusterResourceNamespace,
|
||||||
ACMEHTTP01SolverImage: opts.ACMEHTTP01SolverImage,
|
ACMEHTTP01SolverImage: opts.ACMEHTTP01SolverImage,
|
||||||
ClusterIssuerAmbientCredentials: opts.ClusterIssuerAmbientCredentials,
|
ClusterIssuerAmbientCredentials: opts.ClusterIssuerAmbientCredentials,
|
||||||
IssuerAmbientCredentials: opts.IssuerAmbientCredentials,
|
IssuerAmbientCredentials: opts.IssuerAmbientCredentials,
|
||||||
}),
|
}),
|
||||||
Namespace: defaultNamespace,
|
|
||||||
ClusterResourceNamespace: opts.ClusterResourceNamespace,
|
ClusterResourceNamespace: opts.ClusterResourceNamespace,
|
||||||
}, kubeCfg, nil
|
}, kubeCfg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -233,14 +233,10 @@ const (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
controllerpkg.Register(ControllerName, func(ctx *controllerpkg.Context) controllerpkg.Interface {
|
controllerpkg.Register(ControllerName, func(ctx *controllerpkg.Context) controllerpkg.Interface {
|
||||||
var clusterIssuerInformer cminformers.ClusterIssuerInformer
|
|
||||||
if ctx.Namespace == "" {
|
|
||||||
clusterIssuerInformer = ctx.SharedInformerFactory.Certmanager().V1alpha1().ClusterIssuers()
|
|
||||||
}
|
|
||||||
return New(
|
return New(
|
||||||
ctx.SharedInformerFactory.Certmanager().V1alpha1().Certificates(),
|
ctx.SharedInformerFactory.Certmanager().V1alpha1().Certificates(),
|
||||||
ctx.SharedInformerFactory.Certmanager().V1alpha1().Issuers(),
|
ctx.SharedInformerFactory.Certmanager().V1alpha1().Issuers(),
|
||||||
clusterIssuerInformer,
|
ctx.SharedInformerFactory.Certmanager().V1alpha1().ClusterIssuers(),
|
||||||
ctx.KubeSharedInformerFactory.Core().V1().Secrets(),
|
ctx.KubeSharedInformerFactory.Core().V1().Secrets(),
|
||||||
ctx.KubeSharedInformerFactory.Extensions().V1beta1().Ingresses(),
|
ctx.KubeSharedInformerFactory.Extensions().V1beta1().Ingresses(),
|
||||||
ctx.Client,
|
ctx.Client,
|
||||||
|
|||||||
@ -32,9 +32,6 @@ type Context struct {
|
|||||||
// instances
|
// instances
|
||||||
IssuerFactory issuer.Factory
|
IssuerFactory issuer.Factory
|
||||||
|
|
||||||
// Namespace is a namespace to operate within. This should be used when
|
|
||||||
// constructing SharedIndexInformers for the informer factory.
|
|
||||||
Namespace string
|
|
||||||
// ClusterResourceNamespace is the namespace to store resources created by
|
// ClusterResourceNamespace is the namespace to store resources created by
|
||||||
// non-namespaced resources (e.g. ClusterIssuer) in.
|
// non-namespaced resources (e.g. ClusterIssuer) in.
|
||||||
ClusterResourceNamespace string
|
ClusterResourceNamespace string
|
||||||
|
|||||||
@ -28,9 +28,6 @@ type Context struct {
|
|||||||
// instances
|
// instances
|
||||||
SharedInformerFactory informers.SharedInformerFactory
|
SharedInformerFactory informers.SharedInformerFactory
|
||||||
|
|
||||||
// Namespace is a namespace to operate within. This should be used when
|
|
||||||
// constructing SharedIndexInformers for the informer factory.
|
|
||||||
Namespace string
|
|
||||||
// ClusterResourceNamespace is the namespace to store resources created by
|
// ClusterResourceNamespace is the namespace to store resources created by
|
||||||
// non-namespaced resources (e.g. ClusterIssuer) in.
|
// non-namespaced resources (e.g. ClusterIssuer) in.
|
||||||
ClusterResourceNamespace string
|
ClusterResourceNamespace string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user