Skip to content

Commit

Permalink
Add trafficControlController to handle TrafficControl requests
Browse files Browse the repository at this point in the history
1.Use label selectors to filter Pods running on this Node.
2.Translate the selected Pods to OVS ports, which will be used
  to filter traffic that should be mirrored or redirected.
3.Translate the target device to the OVS port, which will be
  used as the target port the traffic should be mirrored or redirected.
4.Install OpenFlow rules calculated using the above arguments.

Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Apr 27, 2022
1 parent 00f9d98 commit 6979aa2
Show file tree
Hide file tree
Showing 8 changed files with 928 additions and 3 deletions.
13 changes: 11 additions & 2 deletions cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"antrea.io/antrea/pkg/agent/controller/noderoute"
"antrea.io/antrea/pkg/agent/controller/serviceexternalip"
"antrea.io/antrea/pkg/agent/controller/traceflow"
"antrea.io/antrea/pkg/agent/controller/trafficcontrol"
"antrea.io/antrea/pkg/agent/flowexporter"
"antrea.io/antrea/pkg/agent/flowexporter/exporter"
"antrea.io/antrea/pkg/agent/interfacestore"
Expand Down Expand Up @@ -93,10 +94,12 @@ func run(o *Options) error {
crdInformerFactory := crdinformers.NewSharedInformerFactory(crdClient, informerDefaultResync)
traceflowInformer := crdInformerFactory.Crd().V1alpha1().Traceflows()
egressInformer := crdInformerFactory.Crd().V1alpha2().Egresses()
externalIPPoolInformer := crdInformerFactory.Crd().V1alpha2().ExternalIPPools()
trafficControlInformer := crdInformerFactory.Crd().V1alpha2().TrafficControls()
nodeInformer := informerFactory.Core().V1().Nodes()
serviceInformer := informerFactory.Core().V1().Services()
endpointsInformer := informerFactory.Core().V1().Endpoints()
externalIPPoolInformer := crdInformerFactory.Crd().V1alpha2().ExternalIPPools()
namespaceInformer := informerFactory.Core().V1().Namespaces()

// Create Antrea Clientset for the given config.
antreaClientProvider := agent.NewAntreaClientProvider(o.config.AntreaClientConnection, k8sClient)
Expand Down Expand Up @@ -453,7 +456,8 @@ func run(o *Options) error {
// Initialize localPodInformer for NPLAgent, AntreaIPAMController, and secondary network controller.
var localPodInformer cache.SharedIndexInformer
if enableNodePortLocal || enableBridgingMode ||
features.DefaultFeatureGate.Enabled(features.SecondaryNetwork) {
features.DefaultFeatureGate.Enabled(features.SecondaryNetwork) ||
features.DefaultFeatureGate.Enabled(features.TrafficControl) {
listOptions := func(options *metav1.ListOptions) {
options.FieldSelector = fields.OneTermEqualSelector("spec.nodeName", nodeConfig.Name).String()
}
Expand Down Expand Up @@ -523,6 +527,11 @@ func run(o *Options) error {
go podWatchController.Run(stopCh)
}

if features.DefaultFeatureGate.Enabled(features.TrafficControl) {
tcController := trafficcontrol.NewTrafficControlController(ofClient, ifaceStore, ovsBridgeClient, trafficControlInformer, localPodInformer, namespaceInformer)
go tcController.Run(stopCh)
}

// Start the localPodInformer
if localPodInformer != nil {
go localPodInformer.Run(stopCh)
Expand Down
Loading

0 comments on commit 6979aa2

Please sign in to comment.