programming kubernetes chapter 1 - intro [1939b0e5]
Tags: hausenblas - programming kubernetes
- Building native apps that speak to both the kubelet and the API server
-
Extension points
cloud-controller-managerintegrates w/ the cloudkubeletbinary lets network/devices/storage and container runtimeskubectlhas plugins- extensions on API server
- custom resources and controllers
- custom API servers
- scheduler extensions
1. controllers (k8s) and Operators
1. controllers (k8s) and Operators
-
Controllers implement a control loop, watching the shared state of the cluster through the API server and making changes in an attempt to move the current state towards the desired state
- Controllers act on core resources
- Operators are controllers that encode some operational knowledge
-
the controllers pull info, computes the difference between the desired state and the current state, and updates accordingly
- somewhat similar to loss function
1.1. The control loop
1.1. The control loop
- Read state (hopefully event driven)
- Change state
- Update status via API server in etcd
- repeat
1.1.1. Data structures used by the controller
1.1.1. Data structures used by the controller
-
Informers
- Obtains the state of a cluster, often with a resync mechanism
-
Work queues
- used for event handler that handles the queuing of state changes
1.1.2. State transitions
1.1.2. State transitions
- k8s iteratively determines what is the next command to run, when no commands can be run, cluster is in steady state
-
Kubernetes objects
-
kube object store is a set of kube objects
- kube objects are data records that come in
kinds
- kube objects are data records that come in
-
- controller transitions can cascade into one another, state transition from one controller can cause another to happen
- therefore kube objects are records of intent, not records of fact
- ultimately kube does not make coordinated efforts to transition into a desired state
1.1.3. Operators
1.1.3. Operators
Operators encode specific knowledge about the underlying resource, allowing it to manage specific state, shipping with custom resource definitions (crds) and custom controllers
For example, a Cassandra operator can balance nodes accordingly