Skip to content

Commit 8ade99e

Browse files
rjackson90jvassev
authored andcommitted
Efficient Kubernetes API Updates using Informers (#75)
* Add new Datasource based on Kubernetes Informers Within the Go API client, the Kubernetes project has created tools for keeping local references to API resources up to date with the server state. By creating an Informer, the kubernetes API client can perform an intial sync of objects we are interested in and then watch for updates to those objects instead of polling the server on a regular interval. Changing the access pattern of the config reloader is important for scaling kubernetes clusters. If the config reloader is set to poll for updates on a short interval (such as 5 seconds) it can generate quite a significant amount of traffic on the API server even in relatively modest clusters composed of a couple dozen compute nodes. This increase in request volume does not provide any value to the config reloader, and is a potentially expensive side-effect on AWS if some nodes are in a different availability zone from the kubernetes API server(s). By creating this new Datasource, the config reloader can be configured with an arbitrarily short update interval without having to worry about drowning the kubernetes API server in a flood of pointless requests. The Informer datasource maintains watches on important API objects in a separate goroutine, and will make changes available to configreloader updates very quickly, usually on the update immediately following the change in the upstream API. The new Datasource has been designed to be able to replace both existing Kubernetes Datasources, but has only been tested against the behavior of the Kubernetes Multimap Datasource. Signed-off-by: Richard Jackson <[email protected]> * Replace usage of existing Kubernetes Datasources Update the controller to only use the new Informer-based datasource to replace both existing kubernetes datasource implementations. Note: This change has been tested in multiple production-quality clusters for several weeks, but only in a configuration that formerly used the Multimap datasource. Only cursory testing has been done to verify that the new datasource is compatible with the default Kubernetes datasource. Signed-off-by: Richard Jackson <[email protected]> * Remove unused datasources The new Informer-based datasource for Kubernetes has clear benefits in terms of scalability, and should be compatible with the behavior of both existing datasources. Signed-off-by: Richard Jackson <[email protected]>
1 parent a0df480 commit 8ade99e

File tree

4 files changed

+260
-340
lines changed

4 files changed

+260
-340
lines changed

config-reloader/controller/controller.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ func New(cfg *config.Config) (*Controller, error) {
4949
} else if cfg.Datasource == "fs" {
5050
ds = datasource.NewFileSystemDatasource(cfg.FsDatasourceDir, cfg.OutputDir)
5151
} else {
52-
if cfg.Datasource == "multimap" {
53-
ds, err = datasource.NewKubernetesMultimapDatasource(cfg)
54-
} else {
55-
ds, err = datasource.NewKubernetesDatasource(cfg)
56-
}
52+
ds, err = datasource.NewKubernetesInformerDatasource(cfg)
5753
if err != nil {
5854
return nil, err
5955
}

config-reloader/datasource/kube.go

Lines changed: 0 additions & 168 deletions
This file was deleted.

0 commit comments

Comments
 (0)