# IT star is not a dream # illustration of kubernetes container viability mechanism core
K8s builds a Manager component to manage the container probe worker, which is responsible for the management of the underlying worker, caches the current state of the container and synchronizes the current state of the container. Today we will analyze some of its core components.
1. Realization of core principle
The state of the Manager cache is mainly consumed by kubelet and state components, and when the Pod synchronizes the state, it updates the Pod container's readiness and startup status through the probe status in the current Manager. Let's take a look at some key implementations of Manager itself.
two。 Probing result management
That is, prober/results/results_manager component, whose main function is to store and notify detection results.
2.1 Core data structure
Cache is responsible for saving the detection results of the container, while updates is responsible for subscribing to update status. By comparing the new results with the status in cache, it decides whether to notify or not.
/ / Manager implementation.type manager struct {/ / protect cache sync.RWMutex / / Container ID- > probe result cache map [kubecontainer.ContainerID] Result / / Update pipeline updates chan Update} 2.2 update cache notification event
When updating the cache, the kubelet core process of whether or not to publish a change event by comparing the status before and after the change is notified to the external subscription container.
Func (m * manager) Set (id kubecontainer.ContainerID, result Result, pod * v1.Pod) {/ / modify internal state if m.setInternal (id, result) {/ / synchronous update event m.updates