From 4e9ede945f98815a4eefa876530b727c8dddf0db Mon Sep 17 00:00:00 2001 From: wimi <64467336+wimi@users.noreply.github.com> Date: Mon, 13 Jun 2022 14:28:46 +0200 Subject: [PATCH] Added custom parameters to change default resync period values. --- cmd/azure-keyvault-controller/main.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/azure-keyvault-controller/main.go b/cmd/azure-keyvault-controller/main.go index 395b5a62..39812e62 100644 --- a/cmd/azure-keyvault-controller/main.go +++ b/cmd/azure-keyvault-controller/main.go @@ -56,12 +56,14 @@ import ( const controllerAgentName = "azurekeyvaultcontroller" var ( - version string - kubeconfig string - masterURL string - cloudconfig string - logFormat string - watchAllNamespaces bool + version string + kubeconfig string + masterURL string + cloudconfig string + logFormat string + watchAllNamespaces bool + kubeResyncPeriod int + azureKeyVaultResyncPeriod int ) func initConfig() { @@ -81,6 +83,8 @@ func init() { flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") flag.StringVar(&cloudconfig, "cloudconfig", "/etc/kubernetes/azure.json", "Path to cloud config. Only required if this is not at default location /etc/kubernetes/azure.json") flag.BoolVar(&watchAllNamespaces, "watch-all-namespaces", true, "Watch for custom resources in all namespaces, if set to false it will only watch the runtime namespace.") + flag.IntVar(&kubeResyncPeriod, "kube-resync-period", 30, "Resync period for kubernetes changes, in seconds. Defaults to 30.") + flag.IntVar(&azureKeyVaultResyncPeriod, "azure-resync-period", 30, "Resync period for Azure Key Vault changes, in seconds. Defaults to 30.") } func main() { @@ -155,8 +159,8 @@ func main() { options.LabelSelector = labelSelectorAppender(options.LabelSelector, objectLabelSet) })) } - kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*30, kubeInformerOptions...) - azureKeyVaultSecretInformerFactory := informers.NewSharedInformerFactoryWithOptions(azureKeyVaultSecretClient, time.Second*30, akvInformerOptions...) + kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*time.Duration(kubeResyncPeriod), kubeInformerOptions...) + azureKeyVaultSecretInformerFactory := informers.NewSharedInformerFactoryWithOptions(azureKeyVaultSecretClient, time.Second*time.Duration(azureKeyVaultResyncPeriod), akvInformerOptions...) klog.InfoS("Creating event broadcaster") eventBroadcaster := record.NewBroadcaster()