Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom resync periods #371

Merged
merged 2 commits into from
Aug 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions cmd/azure-keyvault-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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()
Expand Down