in pkg/cmd/admissioncontroller/main.go [55:112]
func main() {
configMaps, err := client.LoadBootstrapConfigMaps()
if err != nil {
log.Log(log.Admission).Fatal("Failed to load initial configmaps", zap.Error(err))
return
}
amConf := conf.NewAdmissionControllerConf(configMaps)
kubeClient := client.NewKubeClient(amConf.GetKubeConfig())
informers := admission.NewInformers(kubeClient, amConf.GetNamespace())
if hadlerErr := amConf.RegisterHandlers(informers.ConfigMap); hadlerErr != nil {
log.Log(log.Admission).Fatal("Failed to register handlers", zap.Error(hadlerErr))
return
}
pcCache, pcErr := admission.NewPriorityClassCache(informers.PriorityClass)
if pcErr != nil {
log.Log(log.Admission).Fatal("Failed to create new priority class cache", zap.Error(pcErr))
return
}
nsCache, nsErr := admission.NewNamespaceCache(informers.Namespace)
if nsErr != nil {
log.Log(log.Admission).Fatal("Failed to create namespace cache", zap.Error(nsErr))
return
}
informers.Start()
wm, err := admission.NewWebhookManager(amConf)
if err != nil {
log.Log(log.Admission).Fatal("Failed to initialize webhook manager", zap.Error(err))
}
ac := admission.InitAdmissionController(amConf, pcCache, nsCache)
webhook := CreateWebhook(ac, HTTPPort)
certs := UpdateWebhookConfiguration(wm)
webhook.Startup(certs)
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR1)
WaitForCertExpiration(wm, signalChan)
for {
switch <-signalChan {
case syscall.SIGUSR1: // reload certificates
certs := UpdateWebhookConfiguration(wm)
webhook.Shutdown()
webhook.Startup(certs)
WaitForCertExpiration(wm, signalChan)
default: // terminate
informers.Stop()
webhook.Shutdown()
os.Exit(0)
}
}
}