Change flag to list of controllers to enable
This commit is contained in:
parent
969c4530a0
commit
58d71216c3
@ -22,9 +22,9 @@ import (
|
||||
intscheme "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/scheme"
|
||||
informers "github.com/jetstack/cert-manager/pkg/client/informers/externalversions"
|
||||
"github.com/jetstack/cert-manager/pkg/controller"
|
||||
ingressshimcontroller "github.com/jetstack/cert-manager/pkg/controller/ingress-shim"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer"
|
||||
dnsutil "github.com/jetstack/cert-manager/pkg/issuer/acme/dns/util"
|
||||
"github.com/jetstack/cert-manager/pkg/util"
|
||||
"github.com/jetstack/cert-manager/pkg/util/kube"
|
||||
kubeinformers "k8s.io/client-go/informers"
|
||||
)
|
||||
@ -41,15 +41,16 @@ func Run(opts *options.ControllerOptions, stopCh <-chan struct{}) {
|
||||
run := func(_ <-chan struct{}) {
|
||||
var wg sync.WaitGroup
|
||||
for n, fn := range controller.Known() {
|
||||
// don't enable ingress-shim if it's been disabled
|
||||
if n == ingressshimcontroller.ControllerName && !opts.EnableIngressShim {
|
||||
// only run a controller if it's been enabled
|
||||
if !util.Contains(opts.EnabledControllers, n) {
|
||||
glog.Infof("%s controller is not in list of controllers to enable, so not enabling it", n)
|
||||
continue
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func(n string, fn controller.Interface) {
|
||||
defer wg.Done()
|
||||
glog.V(4).Infof("Starting %s controller", n)
|
||||
glog.Infof("Starting %s controller", n)
|
||||
|
||||
err := fn(5, stopCh)
|
||||
|
||||
|
||||
@ -8,6 +8,11 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/util"
|
||||
|
||||
certificatescontroller "github.com/jetstack/cert-manager/pkg/controller/certificates"
|
||||
clusterissuerscontroller "github.com/jetstack/cert-manager/pkg/controller/clusterissuers"
|
||||
ingressshimcontroller "github.com/jetstack/cert-manager/pkg/controller/ingress-shim"
|
||||
issuerscontroller "github.com/jetstack/cert-manager/pkg/controller/issuers"
|
||||
)
|
||||
|
||||
type ControllerOptions struct {
|
||||
@ -20,7 +25,7 @@ type ControllerOptions struct {
|
||||
LeaderElectionRenewDeadline time.Duration
|
||||
LeaderElectionRetryPeriod time.Duration
|
||||
|
||||
EnableIngressShim bool
|
||||
EnabledControllers []string
|
||||
|
||||
ACMEHTTP01SolverImage string
|
||||
|
||||
@ -47,8 +52,6 @@ const (
|
||||
defaultLeaderElectionRenewDeadline = 10 * time.Second
|
||||
defaultLeaderElectionRetryPeriod = 2 * time.Second
|
||||
|
||||
defaultEnableIngressShim = true
|
||||
|
||||
defaultClusterIssuerAmbientCredentials = true
|
||||
defaultIssuerAmbientCredentials = false
|
||||
|
||||
@ -60,6 +63,13 @@ const (
|
||||
|
||||
var (
|
||||
defaultACMEHTTP01SolverImage = fmt.Sprintf("quay.io/jetstack/cert-manager-acmesolver:%s", util.AppVersion)
|
||||
|
||||
defaultEnabledControllers = []string{
|
||||
issuerscontroller.ControllerName,
|
||||
clusterissuerscontroller.ControllerName,
|
||||
certificatescontroller.ControllerName,
|
||||
ingressshimcontroller.ControllerName,
|
||||
}
|
||||
)
|
||||
|
||||
func NewControllerOptions() *ControllerOptions {
|
||||
@ -71,7 +81,7 @@ func NewControllerOptions() *ControllerOptions {
|
||||
LeaderElectionLeaseDuration: defaultLeaderElectionLeaseDuration,
|
||||
LeaderElectionRenewDeadline: defaultLeaderElectionRenewDeadline,
|
||||
LeaderElectionRetryPeriod: defaultLeaderElectionRetryPeriod,
|
||||
EnableIngressShim: defaultEnableIngressShim,
|
||||
EnabledControllers: defaultEnabledControllers,
|
||||
ClusterIssuerAmbientCredentials: defaultClusterIssuerAmbientCredentials,
|
||||
IssuerAmbientCredentials: defaultIssuerAmbientCredentials,
|
||||
DefaultIssuerName: defaultTLSACMEIssuerName,
|
||||
@ -108,8 +118,8 @@ func (s *ControllerOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
"The duration the clients should wait between attempting acquisition and renewal "+
|
||||
"of a leadership. This is only applicable if leader election is enabled.")
|
||||
|
||||
fs.BoolVar(&s.EnableIngressShim, "enable-ingress-shim", defaultEnableIngressShim, ""+
|
||||
"If true, the ingress-shim component will be enabled")
|
||||
fs.StringSliceVar(&s.EnabledControllers, "controllers", defaultEnabledControllers, ""+
|
||||
"The set of controllers to enable.")
|
||||
|
||||
fs.StringVar(&s.ACMEHTTP01SolverImage, "acme-http01-solver-image", defaultACMEHTTP01SolverImage, ""+
|
||||
"The docker image to use to solve ACME HTTP01 challenges. You most likely will not "+
|
||||
|
||||
Loading…
Reference in New Issue
Block a user