Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to implement Resource extension Mechanism in kubernetes

Shulou Source: shulou.com Published: 2022-06-01 14:57:42 09月23日 Update

Today, I will talk to you about how to achieve the resource expansion mechanism in kubernetes, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

1.PluginManager

PluginManager is an upper-level component that contains the key components from the previous article, coordinates its internal data flow, and provides specific controllers for different plug-ins

1.1 Core data structure

The core structure is actually designed according to the data flow. First, an aware plug-in desiredStateOfWorldPopulator is needed to perceive the creation or deletion of the back-end service, then the perceived events are added to the desiredStateOfWorld expected state cache, and the reconciler is responsible for the underlying registration and offline, and the results are stored in the actualStateOfWorld actual state cache.

Type pluginManager struct {

/ / plug-in awareness

DesiredStateOfWorldPopulator * pluginwatcher.Watcher

/ / Coordinator plug-in

Reconciler reconciler.Reconciler

/ / actual state cache

ActualStateOfWorld cache.ActualStateOfWorld

/ / expected state cache

DesiredStateOfWorld cache.DesiredStateOfWorld

}

1.2 initialization

During initialization, both dsw and asw are given to the reconciler cache for event awareness and update.

Func NewPluginManager (

SockDir string

Recorder record.EventRecorder) PluginManager {

Asw: = cache.NewActualStateOfWorld ()

Dsw: = cache.NewDesiredStateOfWorld ()

/ / both the expected state cache and the actual state cache will be handed over to reconciler

Reconciler: = reconciler.NewReconciler (

Operationexecutor.NewOperationExecutor (

Operationexecutor.NewOperationGenerator (

Recorder

),

),

LoopSleepDuration

Dsw

Asw

)

Pm: = & pluginManager {

/ / launch a watcher and store the dsw expected state cache, and the subsequent reconciler can perceive the new state through the dsw

DesiredStateOfWorldPopulator: pluginwatcher.NewWatcher (

SockDir

Dsw

),

Reconciler: reconciler

DesiredStateOfWorld: dsw

ActualStateOfWorld: asw

}

Return pm

}

1.3 launch the plug-in Manager

In fact, when the plug-in manager starts, the internal desiredStateOfWorldPopulator will talk about watcher-aware events and constantly modify its own internal cache so that reconciler can constantly make calls to the corresponding grpc through the expected state cache to meet the desired state.

Func (pm * pluginManager) Run (sourcesReady config.SourcesReady, stopCh)

Tags: Resources caches states plug-ins expectations data services mechanisms events information reality that is controllers controls content cycles periodicity cores processes disks Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS Huawei MariaDB Docker