1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

refactor: init certs with certs renewer directly (#3853)

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
Charles-Edouard Brétéché 2022-05-10 16:08:36 +02:00 committed by GitHub
parent 2866c06d95
commit ec2bf3b6da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 13 deletions

View file

@ -343,7 +343,10 @@ func main() {
registerWrapperRetry := common.RetryFunc(time.Second, webhookRegistrationTimeout, webhookCfg.Register, "failed to register webhook", setupLog)
registerWebhookConfigurations := func() {
certManager.InitTLSPemPair()
if _, err := certRenewer.InitTLSPemPair(); err != nil {
setupLog.Error(err, "tls initialization error")
os.Exit(1)
}
waitForCacheSync(stopCh, kyvernoInformer, kubeInformer, kubeKyvernoInformer)
// validate the ConfigMap format

View file

@ -18,10 +18,6 @@ type Controller interface {
// Run starts the certManager
Run(stopCh <-chan struct{})
// InitTLSPemPair initializes the TLSPemPair
// it should be invoked by the leader
InitTLSPemPair()
// GetTLSPemPair gets the existing TLSPemPair from the secret
GetTLSPemPair() (*tls.PemPair, error)
}
@ -63,14 +59,6 @@ func (m *controller) updateSecretFunc(oldObj interface{}, newObj interface{}) {
}
}
func (m *controller) InitTLSPemPair() {
_, err := m.renewer.InitTLSPemPair()
if err != nil {
logger.Error(err, "initialization error")
os.Exit(1)
}
}
func (m *controller) GetTLSPemPair() (*tls.PemPair, error) {
secret, err := m.secretLister.Secrets(config.KyvernoNamespace).Get(m.renewer.GenerateTLSPairSecretName())
if err != nil {