深入理解Apollo核心机制之灰度发布——创建灰度

概述

ApolloPortal创建灰度后都做了什么呢?Apollo是如何维护主版本与灰度版本关系的呢?

其实创建灰度非常简单,可以看到下图中“Cluster”表结构中的“ParentClusterId”字段。这个就是维护灰度关系的核心。
在创建灰度的时候,Apollo会根据当前Cluster、Namespace创建对应的子Cluster、子Namespace。其中子Cluster的“ParentClusterId”字段值等于当前Cluster的Id,这样就关联上了。(主版本就是“当前Cluster”下的Namespace,灰度版本就是”子Cluster“下的Namespace)。

总结下来无非就是clone了当前cluster、当前namespace,像数据库中新增了一个cluster(你不能再portal左侧看到),并且新增一个namespace在这个子cluster下而已。不过记得要关联上父子关系就行了。其他的对于灰度版本的namespace的操作就和正常的namespace没什么区别的。

相关数据表结构


核心代码方法

创建子Cluster

保存子Cluster

创建子Namespace

保存子Namespace

原文地址:https://www.cnblogs.com/deepSleeping/p/14565804.html