programming kubernetes chapter 1 - intro
Tags: hausenblas - programming kubernetes
- Building native apps that speak to both the kubelet and the API server
- Extension points
cloud-controller-manager
integrates w/ the cloudkubelet
binary lets network/devices/storage and container runtimeskubectl
has plugins- extensions on API server
- custom resources and controllers
- custom API servers
- scheduler extensions
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
The control loop
- Read state (hopefully event driven)
- Change state
- Update status via API server in etcd
- repeat
-
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
- Informers
-
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
- kube object store is a set of kube objects
- 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
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