k8snetworkplumbingwg / whereabouts

A CNI IPAM plugin that assigns IP addresses cluster-wide
Apache License 2.0
273 stars 120 forks source link

reconciler, cron: allow overriding the reconciler cron expression #397

Closed maiqueb closed 5 months ago

maiqueb commented 6 months ago

What this PR does / why we need it: Provide a config map to override the value of the cron expression. To force reloading this new value, the user should kill the pods in the whereabouts daemonset - the new pods will load the updated value.

The value of the config map is passed to the whereabouts containers as an environment variable.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged): Fixes #

Special notes for your reviewer (optional):

maiqueb commented 6 months ago

Tested locally; one can see in the whereabouts pods:

kubectl exec -it -nkube-system whereabouts-thcs9 -- env | grep RECONCILER_CRON
WHEREABOUTS_RECONCILER_CRON=0-59/2 * * * *

And checking the logs we can see that every two minutes the reconciler cron is triggered:

kubectl logs -nkube-system whereabouts-thcs9 
Done configuring CNI.  Sleep=false
2023-12-19T14:13:16Z [debug] Filtering pods with filter key 'spec.nodeName' and filter value 'whereabouts-worker3'
2023-12-19T14:13:16Z [verbose] pod controller created
2023-12-19T14:13:16Z [verbose] Starting informer factories ...
2023-12-19T14:13:16Z [verbose] Informer factories started
2023-12-19T14:13:16Z [verbose] starting network controller
2023-12-19T14:14:00Z [verbose] starting reconciler run
2023-12-19T14:14:00Z [debug] NewReconcileLooper - inferred connection data
2023-12-19T14:14:00Z [debug] listing IP pools
2023-12-19T14:14:00Z [debug] no IP addresses to cleanup
2023-12-19T14:14:00Z [verbose] reconciler success
2023-12-19T14:16:00Z [verbose] starting reconciler run
2023-12-19T14:16:00Z [debug] NewReconcileLooper - inferred connection data
2023-12-19T14:16:00Z [debug] listing IP pools
2023-12-19T14:16:00Z [debug] no IP addresses to cleanup
2023-12-19T14:16:00Z [verbose] reconciler success
2023-12-19T14:18:00Z [verbose] starting reconciler run
2023-12-19T14:18:00Z [debug] NewReconcileLooper - inferred connection data
2023-12-19T14:18:00Z [debug] listing IP pools
2023-12-19T14:18:00Z [debug] no IP addresses to cleanup
2023-12-19T14:18:00Z [verbose] reconciler success
2023-12-19T14:20:00Z [verbose] starting reconciler run
2023-12-19T14:20:00Z [debug] NewReconcileLooper - inferred connection data
2023-12-19T14:20:00Z [debug] listing IP pools
2023-12-19T14:20:00Z [debug] no IP addresses to cleanup
2023-12-19T14:20:00Z [verbose] reconciler success
2023-12-19T14:22:00Z [verbose] starting reconciler run
2023-12-19T14:22:00Z [debug] NewReconcileLooper - inferred connection data
2023-12-19T14:22:00Z [debug] listing IP pools
2023-12-19T14:22:00Z [debug] no IP addresses to cleanup
2023-12-19T14:22:00Z [verbose] reconciler success
maiqueb commented 5 months ago

Closed in lieu of #398