Skip to content

Commit

Permalink
[Multicast] Add Multicast statistics API and controlplane stats API
Browse files Browse the repository at this point in the history
This PR adds a field MulticastStats for control-plane API NodeStatsSummary
and field MulticastGroupMember for public statistics API group.

Signed-off-by: ceclinux <[email protected]>
  • Loading branch information
ceclinux committed Apr 27, 2022
1 parent 00f9d98 commit 0ade78f
Show file tree
Hide file tree
Showing 14 changed files with 982 additions and 145 deletions.
10 changes: 10 additions & 0 deletions pkg/apis/controlplane/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,16 @@ type NodeStatsSummary struct {
AntreaClusterNetworkPolicies []NetworkPolicyStats
// The TrafficStats of Antrea NetworkPolicies collected from the Node.
AntreaNetworkPolicies []NetworkPolicyStats
// The stats related to multicast collected from the Node.
Multicast []MulticastStats
}

// MulticastStats contains the multicast groups that a Pod has joined.
type MulticastStats struct {
// Group is the IP of Multicast Group.
Group string
// Pods is the list of Pods that has joined the multicast group.
Pods []PodReference
}

// NetworkPolicyStats contains the information and traffic stats of a NetworkPolicy.
Expand Down
573 changes: 429 additions & 144 deletions pkg/apis/controlplane/v1beta2/generated.pb.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions pkg/apis/controlplane/v1beta2/generated.proto

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

10 changes: 10 additions & 0 deletions pkg/apis/controlplane/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,16 @@ type NodeStatsSummary struct {
AntreaClusterNetworkPolicies []NetworkPolicyStats `json:"antreaClusterNetworkPolicies,omitempty" protobuf:"bytes,3,rep,name=antreaClusterNetworkPolicies"`
// The TrafficStats of Antrea NetworkPolicies collected from the Node.
AntreaNetworkPolicies []NetworkPolicyStats `json:"antreaNetworkPolicies,omitempty" protobuf:"bytes,4,rep,name=antreaNetworkPolicies"`
// List of PodMulticast statistics collected from the Node.
Multicast []MulticastStats `json:"multicast,omitempty" protobuf:"bytes,5,rep,name=multicast"`
}

// MulticastStats contains the multicast groups that a Pod has joined.
type MulticastStats struct {
// Group is the IP of Multicast Group.
Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
// Pods is the list of Pods that has joined the multicast group.
Pods []PodReference `json:"pods,omitempty" protobuf:"bytes,2,rep,name=pods"`
}

// NetworkPolicyStats contains the information and traffic stats of a NetworkPolicy.
Expand Down
34 changes: 34 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.

28 changes: 28 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.

28 changes: 28 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.

2 changes: 2 additions & 0 deletions pkg/apis/stats/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&AntreaNetworkPolicyStatsList{},
&NetworkPolicyStats{},
&NetworkPolicyStatsList{},
&MulticastGroupMember{},
&MulticastGroupMemberList{},
)
return nil
}
32 changes: 32 additions & 0 deletions pkg/apis/stats/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,38 @@ type AntreaNetworkPolicyStatsList struct {
Items []AntreaNetworkPolicyStats
}

// PodReference represents a Pod Reference.
type PodReference struct {
// The name of this Pod.
Name string
// The Namespace of this Pod.
Namespace string
}

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

// MulticastGroupMember contains the mapping between Multicast Group and Pods.
type MulticastGroupMember struct {
metav1.TypeMeta
metav1.ObjectMeta

// Group is the IP of Multicast Group.
Group string
// Pods is the list of Pods that has joined the multicast group.
Pods []PodReference
}

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

// MulticastGroupMemberList is a list of MulticastGroupMember.
type MulticastGroupMemberList struct {
metav1.TypeMeta
metav1.ListMeta

// List of MulticastGroupPodsMember.
Items []MulticastGroupMember
}

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

// NetworkPolicyStats is the statistics of a K8s NetworkPolicy.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/stats/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&AntreaNetworkPolicyStatsList{},
&NetworkPolicyStats{},
&NetworkPolicyStatsList{},
&MulticastGroupMember{},
&MulticastGroupMemberList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
36 changes: 36 additions & 0 deletions pkg/apis/stats/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,34 @@ type NetworkPolicyStats struct {
TrafficStats TrafficStats `json:"trafficStats,omitempty" protobuf:"bytes,2,opt,name=trafficStats"`
}

// +genclient
// +resourceName=multicastgroupmembers
// +genclient:readonly
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// MulticastGroupMember contains the mapping between Multicast Group and Pods.
type MulticastGroupMember struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

// Group is the IP of Multicast Group.
Group string `json:"group,omitempty" protobuf:"bytes,2,opt,name=group"`
// Pods is the list of Pods that has joined the multicast group.
Pods []PodReference `json:"pods" protobuf:"bytes,3,rep,name=pods"`
}

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

// MulticastGroupMemberList is a list of MulticastGroupMember.
type MulticastGroupMemberList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

// List of MulticastGroupPodsMember.
Items []MulticastGroupMember `json:"items" protobuf:"bytes,2,rep,name=items"`
}

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

// NetworkPolicyStatsList is a list of NetworkPolicyStats.
Expand All @@ -96,6 +124,14 @@ type NetworkPolicyStatsList struct {
Items []NetworkPolicyStats `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// PodReference represents a Pod Reference.
type PodReference struct {
// The name of this Pod.
Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
// The Namespace of this Pod.
Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"`
}

// TrafficStats contains the traffic stats of a NetworkPolicy.
type TrafficStats struct {
// Packets is the packets count hit by the NetworkPolicy.
Expand Down
Loading

0 comments on commit 0ade78f

Please sign in to comment.