Skip to content

Commit

Permalink
Namespaced Group membership API
Browse files Browse the repository at this point in the history
Currently Antrea supports ClusterGroup and namespaced Group
CRD, but only provides API for ClusterGroup membership.

This solution adds membership API for namespaced Group at
namespacedgroupmembers.controlplane.antrea.io. The group
association API is still available for both ClusterGroup and
namespaced Group.

Fixes #5269

Signed-off-by: Qiyue Yao <yaoq@vmware.com>
  • Loading branch information
qiyueyao committed Aug 24, 2023
1 parent 8ac8a91 commit 064b669
Show file tree
Hide file tree
Showing 25 changed files with 1,414 additions and 272 deletions.
1 change: 1 addition & 0 deletions hack/update-codegen-dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function generate_antrea_client_code {
--plural-exceptions "AntreaNetworkPolicyStats:AntreaNetworkPolicyStats" \
--plural-exceptions "AntreaClusterNetworkPolicyStats:AntreaClusterNetworkPolicyStats" \
--plural-exceptions "ClusterGroupMembers:ClusterGroupMembers" \
--plural-exceptions "GroupMembers:GroupMembers" \
--go-header-file hack/boilerplate/license_header.go.txt

# Generate listers with K8s codegen tools.
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/controlplane/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&NetworkPolicyStatus{},
&NodeStatsSummary{},
&ClusterGroupMembers{},
&GroupMembers{},
&PaginationGetOptions{},
&GroupAssociation{},
&IPGroupAssociation{},
Expand Down
15 changes: 14 additions & 1 deletion pkg/apis/controlplane/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type GroupMember struct {

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterGroupMembers is a list of GroupMember objects or ipBlocks that are currently selected by a ClusterGroup.
// ClusterGroupMembers is a list of GroupMember objects or IPBlocks that are currently selected by a ClusterGroup.
type ClusterGroupMembers struct {
metav1.TypeMeta
metav1.ObjectMeta
Expand All @@ -106,6 +106,19 @@ type ClusterGroupMembers struct {
CurrentPage int64
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// GroupMembers is a list of GroupMember objects or IPBlocks that are currently selected by a Group.
type GroupMembers struct {
metav1.TypeMeta
metav1.ObjectMeta
EffectiveMembers []GroupMember
EffectiveIPBlocks []IPNet
TotalMembers int64
TotalPages int64
CurrentPage int64
}

// +k8s:conversion-gen:explicit-from=net/url.Values
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

Expand Down
772 changes: 565 additions & 207 deletions pkg/apis/controlplane/v1beta2/generated.pb.go

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion pkg/apis/controlplane/v1beta2/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apis/controlplane/v1beta2/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&NetworkPolicyStatus{},
&NodeStatsSummary{},
&ClusterGroupMembers{},
&GroupMembers{},
&PaginationGetOptions{},
&GroupAssociation{},
&IPGroupAssociation{},
Expand Down
17 changes: 16 additions & 1 deletion pkg/apis/controlplane/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type GroupMember struct {
// +genclient:onlyVerbs=get
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterGroupMembers is a list of GroupMember objects or ipBlocks that are currently selected by a ClusterGroup.
// ClusterGroupMembers is a list of GroupMember objects or IPBlocks that are currently selected by a ClusterGroup.
type ClusterGroupMembers struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Expand All @@ -109,6 +109,21 @@ type ClusterGroupMembers struct {
CurrentPage int64 `json:"currentPage" protobuf:"varint,6,opt,name=currentPage"`
}

// +genclient
// +genclient:onlyVerbs=get
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// GroupMembers is a list of GroupMember objects or IPBlocks that are currently selected by a Group.
type GroupMembers struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
EffectiveMembers []GroupMember `json:"effectiveMembers" protobuf:"bytes,2,rep,name=effectiveMembers"`
EffectiveIPBlocks []IPNet `json:"effectiveIPBlocks" protobuf:"bytes,3,rep,name=effectiveIPBlocks"`
TotalMembers int64 `json:"totalMembers" protobuf:"varint,4,opt,name=totalMembers"`
TotalPages int64 `json:"totalPages" protobuf:"varint,5,opt,name=totalPages"`
CurrentPage int64 `json:"currentPage" protobuf:"varint,6,opt,name=currentPage"`
}

// +k8s:conversion-gen:explicit-from=net/url.Values
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

Expand Down
60 changes: 60 additions & 0 deletions pkg/apis/controlplane/v1beta2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions pkg/apis/controlplane/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions pkg/apis/controlplane/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"antrea.io/antrea/pkg/apiserver/registry/networkpolicy/appliedtogroup"
"antrea.io/antrea/pkg/apiserver/registry/networkpolicy/clustergroupmember"
"antrea.io/antrea/pkg/apiserver/registry/networkpolicy/groupassociation"
"antrea.io/antrea/pkg/apiserver/registry/networkpolicy/groupmember"
"antrea.io/antrea/pkg/apiserver/registry/networkpolicy/ipgroupassociation"
"antrea.io/antrea/pkg/apiserver/registry/networkpolicy/networkpolicy"
"antrea.io/antrea/pkg/apiserver/registry/stats/antreaclusternetworkpolicystats"
Expand Down Expand Up @@ -192,6 +193,7 @@ func installAPIGroup(s *APIServer, c completedConfig) error {
networkPolicyStorage := networkpolicy.NewREST(c.extraConfig.networkPolicyStore)
networkPolicyStatusStorage := networkpolicy.NewStatusREST(c.extraConfig.networkPolicyStatusController)
clusterGroupMembershipStorage := clustergroupmember.NewREST(c.extraConfig.networkPolicyController)
groupMembershipStorage := groupmember.NewREST(c.extraConfig.networkPolicyController)
groupAssociationStorage := groupassociation.NewREST(c.extraConfig.networkPolicyController)
ipGroupAssociationStorage := ipgroupassociation.NewREST(c.extraConfig.podInformer, c.extraConfig.eeInformer, c.extraConfig.networkPolicyController, c.extraConfig.networkPolicyController)
nodeStatsSummaryStorage := nodestatssummary.NewREST(c.extraConfig.statsAggregator)
Expand All @@ -208,6 +210,7 @@ func installAPIGroup(s *APIServer, c completedConfig) error {
cpv1beta2Storage["groupassociations"] = groupAssociationStorage
cpv1beta2Storage["ipgroupassociations"] = ipGroupAssociationStorage
cpv1beta2Storage["clustergroupmembers"] = clusterGroupMembershipStorage
cpv1beta2Storage["groupmembers"] = groupMembershipStorage
cpv1beta2Storage["egressgroups"] = egressGroupStorage
cpv1beta2Storage["supportbundlecollections"] = bundleCollectionStorage
cpv1beta2Storage["supportbundlecollections/status"] = bundleCollectionStatusStorage
Expand Down
Loading

0 comments on commit 064b669

Please sign in to comment.