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

Add controller to antrea-agent for implementing Egress #2026

Merged
merged 2 commits into from
Apr 7, 2021
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
52 changes: 52 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,58 @@ 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:
- additionalPrinterColumns:
- description: Specifies the SNAT IP address for the selected workloads.
jsonPath: .spec.egressIP
name: EgressIP
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha2
schema:
openAPIV3Schema:
properties:
spec:
properties:
appliedTo:
properties:
namespaceSelector:
x-kubernetes-preserve-unknown-fields: true
podSelector:
x-kubernetes-preserve-unknown-fields: true
type: object
egressIP:
oneOf:
- format: ipv4
- format: ipv6
type: string
required:
- appliedTo
- egressIP
type: object
required:
- spec
type: object
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
52 changes: 52 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,58 @@ 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:
- additionalPrinterColumns:
- description: Specifies the SNAT IP address for the selected workloads.
jsonPath: .spec.egressIP
name: EgressIP
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha2
schema:
openAPIV3Schema:
properties:
spec:
properties:
appliedTo:
properties:
namespaceSelector:
x-kubernetes-preserve-unknown-fields: true
podSelector:
x-kubernetes-preserve-unknown-fields: true
type: object
egressIP:
oneOf:
- format: ipv4
- format: ipv6
type: string
required:
- appliedTo
- egressIP
type: object
required:
- spec
type: object
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
52 changes: 52 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,58 @@ 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:
- additionalPrinterColumns:
- description: Specifies the SNAT IP address for the selected workloads.
jsonPath: .spec.egressIP
name: EgressIP
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha2
schema:
openAPIV3Schema:
properties:
spec:
properties:
appliedTo:
properties:
namespaceSelector:
x-kubernetes-preserve-unknown-fields: true
podSelector:
x-kubernetes-preserve-unknown-fields: true
type: object
egressIP:
oneOf:
- format: ipv4
- format: ipv6
type: string
required:
- appliedTo
- egressIP
type: object
required:
- spec
type: object
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
52 changes: 52 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,58 @@ 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:
- additionalPrinterColumns:
- description: Specifies the SNAT IP address for the selected workloads.
jsonPath: .spec.egressIP
name: EgressIP
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha2
schema:
openAPIV3Schema:
properties:
spec:
properties:
appliedTo:
properties:
namespaceSelector:
x-kubernetes-preserve-unknown-fields: true
podSelector:
x-kubernetes-preserve-unknown-fields: true
type: object
egressIP:
oneOf:
- format: ipv4
- format: ipv6
type: string
required:
- appliedTo
- egressIP
type: object
required:
- spec
type: object
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
52 changes: 52 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,58 @@ 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:
- additionalPrinterColumns:
- description: Specifies the SNAT IP address for the selected workloads.
jsonPath: .spec.egressIP
name: EgressIP
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha2
schema:
openAPIV3Schema:
properties:
spec:
properties:
appliedTo:
properties:
namespaceSelector:
x-kubernetes-preserve-unknown-fields: true
podSelector:
x-kubernetes-preserve-unknown-fields: true
type: object
egressIP:
oneOf:
- format: ipv4
- format: ipv6
type: string
required:
- appliedTo
- egressIP
type: object
required:
- spec
type: object
served: true
storage: true
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
app: antrea
Expand Down
50 changes: 50 additions & 0 deletions build/yamls/base/crds.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
---
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
required:
- spec
properties:
spec:
type: object
required:
- appliedTo
- egressIP
properties:
appliedTo:
type: object
properties:
podSelector:
x-kubernetes-preserve-unknown-fields: true
namespaceSelector:
x-kubernetes-preserve-unknown-fields: true
egressIP:
type: string
oneOf:
- format: ipv4
- format: ipv6
additionalPrinterColumns:
- description: Specifies the SNAT IP address for the selected workloads.
jsonPath: .spec.egressIP
name: EgressIP
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
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
13 changes: 12 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,11 @@ func run(o *Options) error {
statsCollector = stats.NewCollector(antreaClientProvider, ofClient, networkPolicyController)
}

var egressController *egress.EgressController
if features.DefaultFeatureGate.Enabled(features.Egress) {
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 +289,10 @@ func run(o *Options) error {

go networkPolicyController.Run(stopCh)

if features.DefaultFeatureGate.Enabled(features.Egress) {
go egressController.Run(stopCh)
}

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