in pkg/controller/controller.go [106:163]
func (c *controller) Run(ctx context.Context) error {
defer runtime.HandleCrash()
defer c.ingressQueue.ShutDown()
defer c.ingressResyncQueue.ShutDown()
defer c.managedCertificateQueue.ShutDown()
defer c.managedCertificateResyncQueue.ShutDown()
defer c.healthCheck.Stop()
klog.Info("Controller.Run()")
klog.Info("Start reporting metrics")
go c.metrics.Start(flags.F.PrometheusAddress)
klog.Info("Start liveness probe health checks")
c.healthCheck.StartMonitoring()
c.clients.Run(ctx, c.ingressQueue, c.managedCertificateQueue)
klog.Info("Waiting for cache sync")
cacheCtx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
if !cache.WaitForCacheSync(cacheCtx.Done(), c.clients.HasSynced) {
return fmt.Errorf("Timed out waiting for cache sync")
}
klog.Info("Cache synced")
go wait.Until(
func() {
c.processNext(ctx, c.ingressQueue, liveness.Undefined, c.sync.Ingress)
},
time.Second, ctx.Done())
go wait.Until(
func() {
c.processNext(ctx, c.ingressResyncQueue, liveness.IngressResyncProcess,
c.sync.Ingress)
},
time.Second, ctx.Done())
go wait.Until(
func() {
c.processNext(ctx, c.managedCertificateQueue, liveness.Undefined,
c.sync.ManagedCertificate)
},
time.Second, ctx.Done())
go wait.Until(
func() {
c.processNext(ctx, c.managedCertificateResyncQueue,
liveness.McrtResyncProcess, c.sync.ManagedCertificate)
},
time.Second, ctx.Done())
go wait.Until(func() { c.synchronizeAll(ctx) }, c.resyncInterval, ctx.Done())
go wait.Until(func() { c.reportMetrics() }, time.Minute, ctx.Done())
klog.Info("Waiting for stop signal or error")
<-ctx.Done()
klog.Info("Received stop signal, shutting down")
return nil
}