Control flow

Overview

Firstly, the controller needs to communicate with the apiserver, so there should be a client. And the client request you to tell it

Then you can use the client to listWatch on specific type of kubernetes resource.

For higher performance, it is recommended to use the informer instead of polling apiserver.

Controller

  1. informer lists/watches the apiserver and stores the resources in local cache .
  2. It calls the registered callbacks ResourceEventHandler when the add/update/delete events occur.
  3. Then the worker can access the resources by lister without connecting to apiserver.
  4. After receiving the events, the controller does some particular logic to sync the changed resource. Maybe creating new pods, scaling up/dowm deployments, etc.

Clients

clientset

Clientset contains the clients for groups. Each group has exactly one version included in a Clientset.

dynamic client

A dynamic client that can perform generic operations on arbitrary Kubernetes API objects.

RESTClient