New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: add support for envbinding with namespace selector #2432
Conversation
ed4f276
to
4f2442a
Compare
4f2442a
to
409fe1b
Compare
The injection of namespace in #ApplyComponent is not very elegant. It is now closely coupled with multi-cluster and ApplyComponent. Any recommendation for the code architecture? @leejanee @hongchaodeng |
Codecov Report
@@ Coverage Diff @@
## master #2432 +/- ##
==========================================
+ Coverage 61.13% 61.20% +0.07%
==========================================
Files 160 160
Lines 16997 17014 +17
==========================================
+ Hits 10391 10414 +23
+ Misses 5490 5484 -6
Partials 1116 1116
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
9d879f3
to
db75396
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm after nit
@@ -32,6 +32,11 @@ import ( | |||
"github.com/oam-dev/kubevela/pkg/multicluster" | |||
) | |||
|
|||
const ( | |||
// OverrideNamespaceLabelKey identifies the override namespace for patched Application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override namespace 是用来干什么的?解释一下?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在原始不设置 namespace 的情况下,EnvBinding 的每个 Env 下的 Application 里的 Component 可以跨 Namespace 放置资源。这里的 Override Namespace 的意思是用户可以在 Env 里面指定 Namespace 让对应的资源全都放置在 Env 指定的 Namespace 下。
func (engine *ClusterGatewayEngine) prepare(ctx context.Context, configs []v1alpha1.EnvConfig) error { | ||
engine.clusterDecisions = make(map[string]v1alpha1.ClusterDecision) | ||
clusterNameToConfig := make(map[string]string) | ||
locationToConfig := make(map[string]string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
locationToConfig 是做什么的?还有下面这段 forloop 代码太复杂了,需要重构下成更小的函数,用函数名来介绍下做什么的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是做一个简单的重复检查,如果有两个 Env 它们指向了同一个 Cluster 的同一个 Namespace,就会报错。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在这个 forloop 里加了一些注释来标识每段代码的作用
clusterSelector: | ||
name: local | ||
- name: test | ||
placement: # selecting the namespace to deploy to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要解释一下 namespace 是指子集群的 namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 docs/example
里面加个例子?
Successfully created backport PR #2440 for |
Description of your changes
Previous EnvBinding (cluster-gateway mode) only support ClusterSelector (only cluster name is supported). Other legacy modes (like single-cluster & ocm) breaks as workflow is reworked. In this PR, we support NamespaceSelector (only namespace name currently) in EnvBinding. Now we can simultaneously set ClusterSelector and NamespaceSelector in one environment or use them separately. For example, we can deploy application in
prod
namespace in subworker
cluster. Example:I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.Future work from this PR:
a. Support hierarchical grouping for deploy locations.
b. Support workload orchestration across namespace/cluster/region.
How has this code been tested
Special notes for your reviewer