加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_丽江站长网 (http://www.0888zz.com/)- 科技、建站、数据工具、云上网络、机器学习!
当前位置: 首页 > 综合聚焦 > 移动互联 > 评测 > 正文

一篇文章带你了解kubernetes各组件间的通信机制

发布时间:2019-11-05 03:04:20 所属栏目:评测 来源:云端密码
导读:副标题#e# 我们对kubernetes有了一定的认识,本文我们将继续深入的对kubernetes在系统层面上进行讨论,一起看看kubernetes的各个基本组件,以及各个组件是如何相互配合来撑起如此复杂的集群系统。下面跟随文章内容,一起来领略kubernetes令人惊叹的设计内幕

3 创建了watcher,但谁来接收并缓存etcd的数据呢?Apiserver使用cacher来接收etcd的事件,cacher也是Storage类型,这里cacher可以理解为是监听etcd的一个实例,cacher针对于某个类型的数据,其cacher通过ListAndWatch()这个方法,向etcd发送watch请求。etcd会将某一类型的数据同步到watchCache这个结构,也就是说,ListAndWatch()将远端数据源源不断同步到cacher结构中来。Cacher的结构如下所示:

  1. type Cacher struct { 
  2.  incomingHWM storage.HighWaterMark 
  3.  incoming chan watchCacheEvent 
  4.  sync.RWMutex 
  5.  // Before accessing the cacher's cache, wait for the ready to be ok. 
  6.  // This is necessary to prevent users from accessing structures that are 
  7.  // uninitialized or are being repopulated right now. 
  8.  // ready needs to be set to false when the cacher is paused or stopped. 
  9.  // ready needs to be set to true when the cacher is ready to use after 
  10.  // initialization. 
  11.  ready *ready 
  12.  // Underlying storage.Interface. 
  13.  storage storage.Interface 
  14.  // Expected type of objects in the underlying cache. 
  15.  objectType reflect.Type 
  16.  // "sliding window" of recent changes of objects and the current state. 
  17.  watchCache *watchCache 
  18.  reflector *cache.Reflector 
  19.  // Versioner is used to handle resource versions. 
  20.  versioner storage.Versioner 
  21.  // newFunc is a function that creates new empty object storing a object of type Type. 
  22.  newFunc func() runtime.Object 
  23.  // indexedTrigger is used for optimizing amount of watchers that needs to process 
  24.  // an incoming event. 
  25.  indexedTrigger *indexedTriggerFunc 
  26.  // watchers is mapping from the value of trigger function that a 
  27.  // watcher is interested into the watchers 
  28.  watcherIdx int 
  29.  watchers indexedWatchers 
  30.  // Defines a time budget that can be spend on waiting for not-ready watchers 
  31.  // while dispatching event before shutting them down. 
  32.  dispatchTimeoutBudget *timeBudget 
  33.  // Handling graceful termination. 
  34.  stopLock sync.RWMutex 
  35.  stopped bool 
  36.  stopCh chan struct{} 
  37.  stopWg sync.WaitGroup 
  38.  clock clock.Clock 
  39.  // timer is used to avoid unnecessary allocations in underlying watchers. 
  40.  timer *time.Timer 
  41.  // dispatching determines whether there is currently dispatching of 
  42.  // any event in flight. 
  43.  dispatching bool 
  44.  // watchersBuffer is a list of watchers potentially interested in currently 
  45.  // dispatched event. 
  46.  watchersBuffer []*cacheWatcher 
  47.  // blockedWatchers is a list of watchers whose buffer is currently full. 
  48.  blockedWatchers []*cacheWatcher 
  49.  // watchersToStop is a list of watchers that were supposed to be stopped 
  50.  // during current dispatching, but stopping was deferred to the end of 
  51.  // dispatching that event to avoid race with closing channels in watchers. 
  52.  watchersToStop []*cacheWatcher 
  53.  // Maintain a timeout queue to send the bookmark event before the watcher times out. 
  54.  bookmarkWatchers *watcherBookmarkTimeBuckets 
  55.  // watchBookmark feature-gate 
  56.  watchBookmarkEnabled bool 
  57. }  

(编辑:应用网_丽江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读