-
Notifications
You must be signed in to change notification settings - Fork 372
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
Add ACNP copy span for multi-cluster #3363
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3363 +/- ##
===========================================
- Coverage 65.56% 54.99% -10.58%
===========================================
Files 268 375 +107
Lines 26909 51719 +24810
===========================================
+ Hits 17643 28443 +10800
- Misses 7354 20793 +13439
- Partials 1912 2483 +571
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@Dyanngg the unit test and DCO check are failed, you may take a look at them first. |
7d637a9
to
c132869
Compare
Fixed |
c132869
to
3bbd2f5
Compare
multicluster/apis/multicluster/v1alpha1/resourceexport_webhook.go
Outdated
Show resolved
Hide resolved
multicluster/config/crd/bases/multicluster.crd.antrea.io_acnpimports.yaml
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/resourceimport_controller.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/resourceexport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/resourceimport_controller.go
Outdated
Show resolved
Hide resolved
2c34d57
to
43fcb0c
Compare
/test-multicluster-e2e |
@Dyanngg you probably need to rebase the codes,there is a github build error from |
1229564
to
b7f8cb9
Compare
b7f8cb9
to
405369e
Compare
fbc8122
to
a3bf01a
Compare
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Show resolved
Hide resolved
/test-multicluster-e2e |
7c97846
to
bc9b6c1
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 overall, two minor comments.
multicluster/controllers/multicluster/resourceexport_controller.go
Outdated
Show resolved
Hide resolved
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
/test-all E2E test for this feature is passing according to #3435 |
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 overall, one nit
func randSeq(n int) string { | ||
b := make([]rune, n) | ||
for i := range b { | ||
// #nosec G404: random number generator not used for security purposes | ||
randIdx := rand.Intn(len(lettersAndDigits)) | ||
b[i] = lettersAndDigits[randIdx] | ||
} | ||
return string(b) | ||
} | ||
|
||
func randName(prefix string) string { | ||
return prefix + randSeq(nameSuffixLength) | ||
} |
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.
I noticed there are a few duplicate code in test framework, can we share them somewhere? maybe address it in a separate PR.
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.
Sure
No further comment from me. |
@@ -63,6 +64,8 @@ type ResourceExportSpec struct { | |||
Endpoints *EndpointsExport `json:"endpoints,omitempty"` | |||
// If exported resource is ExternalEntity. | |||
ExternalEntity *ExternalEntityExport `json:"externalentity,omitempty"` | |||
// If exported resource is AntreaClusterNetworkPolicy. | |||
ClusterNetworkPolicy *v1alpha1.ClusterNetworkPolicySpec `json:"clusternetworkpolicy,omitempty"` |
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.
Not starting from this PR, the json field name is not following the convention, which should be "clusterNetworkPolicy".
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.
Let's address json field names in a separate PR then.
multicluster/build/yamls/antrea-multicluster-leader-namespaced.yml
Outdated
Show resolved
Hide resolved
multicluster/build/yamls/antrea-multicluster-leader-namespaced.yml
Outdated
Show resolved
Hide resolved
multicluster/build/yamls/antrea-multicluster-leader-namespaced.yml
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Outdated
Show resolved
Hide resolved
multicluster/controllers/multicluster/commonarea/acnp_resourceimport_controller.go
Outdated
Show resolved
Hide resolved
FirstTimestamp: metav1.Now(), | ||
LastTimestamp: metav1.Now(), | ||
ReportingController: acnpEventReportingController, | ||
ReportingInstance: acnpEventReportingInstance, |
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.
this could be the podName?
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.
Yes, see my TODO on L41
- list | ||
- patch | ||
- update | ||
- watch |
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.
does leader need any cnp permission?
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.
No it does not. However this rbac manifest is generated and the only place I've added cnp permissions is in resourceimport_controller.go:
//+kubebuilder:rbac:groups=crd.antrea.io,resources=clusternetworkpolicies,verbs=get;list;watch;create;update;patch;delete
Not sure how to strip this permission from leader cluster specifically. @luolanzone any ideas?
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.
When we split them into member and leader manifests, we didn't separate these accesses setting in fine-grained way, I think we may need a follow up PR to fix these access right. I will create an issue for this first.
@tnqn do you think it's OK to fix this kind of issue in a new PR?
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.
Yes, but please address it in release 1.6. We had such issues before and should ensure all components only get permissions they require.
Signed-off-by: Yang Ding <[email protected]>
Signed-off-by: Yang Ding <[email protected]>
Signed-off-by: Yang Ding <[email protected]>
Signed-off-by: Yang Ding <[email protected]>
Signed-off-by: Yang Ding <[email protected]>
Signed-off-by: Yang Ding <[email protected]>
Signed-off-by: Yang Ding <[email protected]>
f7e29a8
to
2982920
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
- list | ||
- patch | ||
- update | ||
- watch |
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.
Yes, but please address it in release 1.6. We had such issues before and should ensure all components only get permissions they require.
/test-all |
/skip-conformance |
3 similar comments
/skip-conformance |
/skip-conformance |
/skip-conformance |
/test-conformance |
Conformance succeeded but failed on cleanup |
With this change, Antrea Multi-cluster admins can specify certain ClusterNetworkPolicies to be replicated
across the entire ClusterSet. This is especially useful for ClusterSet admins who want all clusters in the
ClusterSet to be applied with a consistent security posture (for example, all namespaces in all clusters can
only communicate with Pods in their own namespaces).
To achieve such ACNP copy-span, admins can, in the acting leader cluster of a Multi-cluster deployment,
create a ResourceExport of kind
AntreaClusterNetworkPolicy
which contains the ClusterNetworkPolicy specthey wish to be replicated. The ResourceExport should be created in the Namespace which implements the
Common Area of the ClusterSet. In future releases, some additional tooling may become available to
automate the creation of such ResourceExport and make ACNP replication across clusters easier.
The above sample spec will create an ACNP in each member cluster which implements strict namespace
isolation for that cluster.