Skip to content
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

Change toService.scope to enum #4562

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/charts/antrea/crds/clusternetworkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ spec:
type: string
scope:
type: string
enum: [ 'Cluster', 'ClusterSet' ]
name:
type: string
enableLogging:
Expand Down
1 change: 1 addition & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ spec:
type: string
scope:
type: string
enum: [ 'Cluster', 'ClusterSet' ]
name:
type: string
enableLogging:
Expand Down
1 change: 1 addition & 0 deletions build/yamls/antrea-crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ spec:
type: string
scope:
type: string
enum: [ 'Cluster', 'ClusterSet' ]
name:
type: string
enableLogging:
Expand Down
1 change: 1 addition & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ spec:
type: string
scope:
type: string
enum: [ 'Cluster', 'ClusterSet' ]
name:
type: string
enableLogging:
Expand Down
1 change: 1 addition & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ spec:
type: string
scope:
type: string
enum: [ 'Cluster', 'ClusterSet' ]
name:
type: string
enableLogging:
Expand Down
1 change: 1 addition & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ spec:
type: string
scope:
type: string
enum: [ 'Cluster', 'ClusterSet' ]
name:
type: string
enableLogging:
Expand Down
1 change: 1 addition & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,7 @@ spec:
type: string
scope:
type: string
enum: [ 'Cluster', 'ClusterSet' ]
name:
type: string
enableLogging:
Expand Down
35 changes: 29 additions & 6 deletions multicluster/test/e2e/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,48 @@ func (data *MCTestData) testANPToServices(t *testing.T) {
eastGwClientName := getClusterGatewayClientPodName(eastCluster)
eastRegularClientName := getClusterRegularClientPodName(eastCluster)

// Verify that ACNP ToServices works fine with the new Multi-cluster Service.
anpBuilder := &e2euttils.AntreaNetworkPolicySpecBuilder{}
anpBuilder = anpBuilder.SetName(multiClusterTestNamespace, "block-west-exported-service").
// Verify that ANP ToServices works fine with the new Multi-cluster Service.
anpBuilder1 := &e2euttils.AntreaNetworkPolicySpecBuilder{}
anpBuilder1 = anpBuilder1.SetName(multiClusterTestNamespace, "block-west-exported-service").
SetPriority(1.0).
SetAppliedToGroup([]e2euttils.ANPAppliedToSpec{{PodSelector: map[string]string{"app": "client"}}}).
AddToServicesRule([]crdv1alpha1.PeerService{{
Name: mcWestClusterTestService,
Namespace: multiClusterTestNamespace},
}, "", nil, crdv1alpha1.RuleActionDrop)
if _, err := data.createOrUpdateANP(eastCluster, anpBuilder.Get()); err != nil {
t.Fatalf("Error creating ANP %s: %v", anpBuilder.Name, err)
if _, err := data.createOrUpdateANP(eastCluster, anpBuilder1.Get()); err != nil {
t.Fatalf("Error creating ANP %s: %v", anpBuilder1.Name, err)
}
defer data.deleteANP(eastCluster, multiClusterTestNamespace, anpBuilder.Name)

connectivity := data.probeFromPodInCluster(eastCluster, multiClusterTestNamespace, eastGwClientName, "client", eastIP, mcWestClusterTestService, 80, corev1.ProtocolTCP)
assert.Equal(t, antreae2e.Dropped, connectivity, "Failure -- wrong result from probing exported Service from gateway clientPod after applying toServices AntreaNetworkPolicy")

connectivity = data.probeFromPodInCluster(eastCluster, multiClusterTestNamespace, eastRegularClientName, "client", eastIP, mcWestClusterTestService, 80, corev1.ProtocolTCP)
assert.Equal(t, antreae2e.Dropped, connectivity, "Failure -- wrong result from probing exported Service from regular clientPod after applying toServices AntreaNetworkPolicy")

data.deleteANP(eastCluster, multiClusterTestNamespace, anpBuilder1.Name)

// Verify that ANP ToServices with scope works fine.
anpBuilder2 := &e2euttils.AntreaNetworkPolicySpecBuilder{}
anpBuilder2 = anpBuilder2.SetName(multiClusterTestNamespace, "block-west-service-clusterset-scope").
SetPriority(1.0).
SetAppliedToGroup([]e2euttils.ANPAppliedToSpec{{PodSelector: map[string]string{"app": "client"}}}).
AddToServicesRule([]crdv1alpha1.PeerService{{
Name: westClusterTestService,
Namespace: multiClusterTestNamespace,
Scope: "ClusterSet",
}}, "", nil, crdv1alpha1.RuleActionDrop)
if _, err := data.createOrUpdateANP(eastCluster, anpBuilder2.Get()); err != nil {
t.Fatalf("Error creating ANP %s: %v", anpBuilder2.Name, err)
}
defer data.deleteANP(eastCluster, multiClusterTestNamespace, anpBuilder2.Name)

connectivity = data.probeFromPodInCluster(eastCluster, multiClusterTestNamespace, eastGwClientName, "client", eastIP, mcWestClusterTestService, 80, corev1.ProtocolTCP)
assert.Equal(t, antreae2e.Dropped, connectivity, "Failure -- wrong result from probing exported Service from gateway clientPod after applying toServices AntreaNetworkPolicy")

connectivity = data.probeFromPodInCluster(eastCluster, multiClusterTestNamespace, eastRegularClientName, "client", eastIP, mcWestClusterTestService, 80, corev1.ProtocolTCP)
assert.Equal(t, antreae2e.Dropped, connectivity, "Failure -- wrong result from probing exported Service from regular clientPod after applying toServices AntreaNetworkPolicy")

}

func (data *MCTestData) testStretchedNetworkPolicy(t *testing.T) {
Expand Down