mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
e3b74f1384
* 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>
47 lines
1.5 KiB
Go
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
|
|
}
|