Skip to content

Commit

Permalink
Add controller to antrea-agent for implementing Egress
Browse files Browse the repository at this point in the history
  • Loading branch information
tnqn committed Apr 5, 2021
1 parent 93cf251 commit 5fdb6d2
Show file tree
Hide file tree
Showing 12 changed files with 1,146 additions and 9 deletions.
24 changes: 24 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@ spec:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
name: egresses.crd.antrea.io
spec:
group: crd.antrea.io
names:
kind: Egress
plural: egresses
shortNames:
- eg
singular: egress
scope: Cluster
versions:
- name: v1alpha2
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
24 changes: 24 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@ spec:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
name: egresses.crd.antrea.io
spec:
group: crd.antrea.io
names:
kind: Egress
plural: egresses
shortNames:
- eg
singular: egress
scope: Cluster
versions:
- name: v1alpha2
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
24 changes: 24 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@ spec:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
name: egresses.crd.antrea.io
spec:
group: crd.antrea.io
names:
kind: Egress
plural: egresses
shortNames:
- eg
singular: egress
scope: Cluster
versions:
- name: v1alpha2
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
24 changes: 24 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@ spec:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
name: egresses.crd.antrea.io
spec:
group: crd.antrea.io
names:
kind: Egress
plural: egresses
shortNames:
- eg
singular: egress
scope: Cluster
versions:
- name: v1alpha2
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
24 changes: 24 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,30 @@ spec:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
name: egresses.crd.antrea.io
spec:
group: crd.antrea.io
names:
kind: Egress
plural: egresses
shortNames:
- eg
singular: egress
scope: Cluster
versions:
- name: v1alpha2
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
22 changes: 22 additions & 0 deletions build/yamls/base/crds.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: egresses.crd.antrea.io
spec:
group: crd.antrea.io
versions:
- name: v1alpha2
served: true
storage: true
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
scope: Cluster
names:
plural: egresses
singular: egress
kind: Egress
shortNames:
- eg
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: antreacontrollerinfos.crd.antrea.io
spec:
Expand Down
8 changes: 7 additions & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/vmware-tanzu/antrea/pkg/agent/cniserver"
_ "github.com/vmware-tanzu/antrea/pkg/agent/cniserver/ipam"
"github.com/vmware-tanzu/antrea/pkg/agent/config"
"github.com/vmware-tanzu/antrea/pkg/agent/controller/egress"
"github.com/vmware-tanzu/antrea/pkg/agent/controller/networkpolicy"
"github.com/vmware-tanzu/antrea/pkg/agent/controller/noderoute"
"github.com/vmware-tanzu/antrea/pkg/agent/controller/traceflow"
Expand Down Expand Up @@ -75,6 +76,7 @@ func run(o *Options) error {
informerFactory := informers.NewSharedInformerFactory(k8sClient, informerDefaultResync)
crdInformerFactory := crdinformers.NewSharedInformerFactory(crdClient, informerDefaultResync)
traceflowInformer := crdInformerFactory.Crd().V1alpha1().Traceflows()
egressInformer := crdInformerFactory.Crd().V1alpha2().Egresses()

// Create Antrea Clientset for the given config.
antreaClientProvider := agent.NewAntreaClientProvider(o.config.AntreaClientConnection, k8sClient)
Expand All @@ -99,7 +101,7 @@ func run(o *Options) error {
ofClient := openflow.NewClient(o.config.OVSBridge, ovsBridgeMgmtAddr, ovsDatapathType,
features.DefaultFeatureGate.Enabled(features.AntreaProxy),
features.DefaultFeatureGate.Enabled(features.AntreaPolicy),
false)
features.DefaultFeatureGate.Enabled(features.Egress))

_, serviceCIDRNet, _ := net.ParseCIDR(o.config.ServiceCIDR)
var serviceCIDRNetv6 *net.IPNet
Expand Down Expand Up @@ -191,6 +193,8 @@ func run(o *Options) error {
statsCollector = stats.NewCollector(antreaClientProvider, ofClient, networkPolicyController)
}

egressController := egress.NewEgressController(ofClient, egressInformer, antreaClientProvider, ifaceStore, routeClient, nodeConfig.Name)

var proxier proxy.Proxier
if features.DefaultFeatureGate.Enabled(features.AntreaProxy) {
v4Enabled := config.IsIPv4Enabled(nodeConfig, networkConfig.TrafficEncapMode)
Expand Down Expand Up @@ -282,6 +286,8 @@ func run(o *Options) error {

go networkPolicyController.Run(stopCh)

go egressController.Run(stopCh)

if features.DefaultFeatureGate.Enabled(features.NetworkPolicyStats) {
go statsCollector.Run(stopCh)
}
Expand Down
Loading

0 comments on commit 5fdb6d2

Please sign in to comment.