Kubernetes Clients
How the framework connects to Kubernetes clusters
When a component resource is reconciled, two Kubernetes API clients are constructed:
- The local client; it always points to the cluster where the component resides. If the component implements impersonation (that is, the component type or its spec implements the
ImpersonationConfigurationinterface), and an impersonation user or groups are specified by the component resource, then the specified user and groups are used to impersonate the controller’s kubeconfig. Otherwise, if aDefaultServiceAccountis defined in the reconciler’s options, then that service account (relative to the componentsmetadata.namespace) is used to impersonate the controller’s kubeconfig. Otherwise, the controller’s kubeconfig itself is used to build the local client. The local client is passed to generators via their context. For example, theHelmGeneratorandKustomizeGeneratorprovided by component-operator-runtime use the local client to realize thelocalLookupandmustLocalLookuptemplate functions. - The target client; if the component specifies a kubeconfig (by implementing the
ClientConfigurationinterface), then that kubeconfig is used to build the target client. Otherwise, a local client is used (possibly impersonated), created according the the logic described above. The target client is used to manage dependent objects, and is passed to generators via their context. For example, theHelmGeneratorandKustomizeGeneratorprovided by component-operator-runtime use the target client to realize thelookupandmustLookuptemplate functions.