What is the reconciliation time for a controller in kubernetes deployed with operator-sdk or in general? Can you set a custom time to recon?

4/30/2019

Kubernetes Controllers / Operators are one of the patterns to develop Kubernetes applications. One of the core Kubernetes processes that run is the controller reconciliation loop.

I would like to know what is the default time interval the recon loop is called or triggered?

Is it possible to modify this interval to trigger the recon loop if there are no events captured by the controller?

-- subodev
controller
kubernetes

1 Answer

5/1/2019

The answer here is: it really depends on the controller. For example, if you see the kube-controller-manager options you'll see that the single binary includes all these controllers:

attachdetach, bootstrapsigner, cloud-node-lifecycle, clusterrole-aggregation, cronjob, csrapproving, csrcleaner, csrsigning, daemonset, deployment, disruption, endpoint, garbagecollector, horizontalpodautoscaling, job, namespace, nodeipam, nodelifecycle, persistentvolume-binder, persistentvolume-expander, podgc, pv-protection, pvc-protection, replicaset, replicationcontroller, resourcequota, root-ca-cert-publisher, route, service, serviceaccount, serviceaccount-token, statefulset, tokencleaner, ttl, ttl-after-finished

Some of them have configurable sync periods and some don't (Built into the controller). For example for Deployments:

--deployment-controller-sync-period duration     Default: 30s

As you may be aware, the way the sync process works is first the controller listens to informers then if there's an update on an informer the controller puts the update in a work queue, then the sync process kicks in every so often. In this example, a sample controller, that time is determined by the second parameter of this call:

// time.Second means 1 second
go wait.Until(c.runWorker, time.Second, stopCh)

Until is an api-machinery function described here.

Keep in mind that the example has a threadiness of 2, meaning that two sync operations can happen at the same time.

-- Rico
Source: StackOverflow