diff --git a/cmd/kyverno/main.go b/cmd/kyverno/main.go index 6e7fb495b5..1078747ab6 100644 --- a/cmd/kyverno/main.go +++ b/cmd/kyverno/main.go @@ -723,7 +723,14 @@ func main() { controller.run(signalCtx, logger.WithName("controllers"), &wg) } // start leader election - go le.Run(signalCtx) + go func() { + select { + case <-signalCtx.Done(): + return + default: + le.Run(signalCtx) + } + }() // create webhooks server urgen := webhookgenerate.NewGenerator( kyvernoClient,