Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Resource extension Mechanism in kubernetes

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report