diff --git a/cmd/azure-keyvault-controller/main.go b/cmd/azure-keyvault-controller/main.go index 17b04460..62bb9b2e 100644 --- a/cmd/azure-keyvault-controller/main.go +++ b/cmd/azure-keyvault-controller/main.go @@ -57,12 +57,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() { @@ -82,6 +84,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() { @@ -158,8 +162,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()