1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/cmd/internal/configmap.go
Vishal Choudhary e3b74f1384
feat: add options to configure resync period for informers in helm chart (#11420)
* feat: add options to configure resync period for informers in helm chart

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

* fix: codegen

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>

---------

Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
2024-10-17 15:23:17 +08:00

47 lines
1.5 KiB
Go

package internal
import (
"context"
"github.com/go-logr/logr"
"github.com/kyverno/kyverno/pkg/config"
genericconfigmapcontroller "github.com/kyverno/kyverno/pkg/controllers/generic/configmap"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
)
func startConfigController(ctx context.Context, logger logr.Logger, client kubernetes.Interface, skipResourceFilters bool) config.Configuration {
configuration := config.NewDefaultConfiguration(skipResourceFilters)
configurationController := genericconfigmapcontroller.NewController(
"config-controller",
client,
resyncPeriod,
config.KyvernoNamespace(),
config.KyvernoConfigMapName(),
func(ctx context.Context, cm *corev1.ConfigMap) error {
configuration.Load(cm)
return nil
},
)
checkError(logger, configurationController.WarmUp(ctx), "failed to init config controller")
go configurationController.Run(ctx, 1)
return configuration
}
func startMetricsConfigController(ctx context.Context, logger logr.Logger, client kubernetes.Interface) config.MetricsConfiguration {
configuration := config.NewDefaultMetricsConfiguration()
configurationController := genericconfigmapcontroller.NewController(
"metrics-config-controller",
client,
resyncPeriod,
config.KyvernoNamespace(),
config.KyvernoMetricsConfigMapName(),
func(ctx context.Context, cm *corev1.ConfigMap) error {
configuration.Load(cm)
return nil
},
)
checkError(logger, configurationController.WarmUp(ctx), "failed to init metrics config controller")
go configurationController.Run(ctx, 1)
return configuration
}