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 selecting egress's owner node and assign egress-ip to owner node #2225

Closed
wants to merge 2 commits into from
Closed
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
14 changes: 14 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,10 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: The Owner Node of egress IP
jsonPath: .status.nodeName
name: Status
type: string
name: v1alpha2
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -1415,11 +1419,18 @@ spec:
required:
- appliedTo
type: object
status:
properties:
nodeName:
type: string
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -3278,10 +3289,13 @@ rules:
- crd.antrea.io
resources:
- egresses
- egresses/status
verbs:
- get
- watch
- list
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
14 changes: 14 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,10 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: The Owner Node of egress IP
jsonPath: .status.nodeName
name: Status
type: string
name: v1alpha2
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -1415,11 +1419,18 @@ spec:
required:
- appliedTo
type: object
status:
properties:
nodeName:
type: string
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -3278,10 +3289,13 @@ rules:
- crd.antrea.io
resources:
- egresses
- egresses/status
verbs:
- get
- watch
- list
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
14 changes: 14 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,10 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: The Owner Node of egress IP
jsonPath: .status.nodeName
name: Status
type: string
name: v1alpha2
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -1415,11 +1419,18 @@ spec:
required:
- appliedTo
type: object
status:
properties:
nodeName:
type: string
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -3278,10 +3289,13 @@ rules:
- crd.antrea.io
resources:
- egresses
- egresses/status
verbs:
- get
- watch
- list
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
14 changes: 14 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,10 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: The Owner Node of egress IP
jsonPath: .status.nodeName
name: Status
type: string
name: v1alpha2
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -1415,11 +1419,18 @@ spec:
required:
- appliedTo
type: object
status:
properties:
nodeName:
type: string
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -3278,10 +3289,13 @@ rules:
- crd.antrea.io
resources:
- egresses
- egresses/status
verbs:
- get
- watch
- list
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
14 changes: 14 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,10 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: The Owner Node of egress IP
jsonPath: .status.nodeName
name: Status
type: string
name: v1alpha2
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -1415,11 +1419,18 @@ spec:
required:
- appliedTo
type: object
status:
properties:
nodeName:
type: string
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -3278,10 +3289,13 @@ rules:
- crd.antrea.io
resources:
- egresses
- egresses/status
verbs:
- get
- watch
- list
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
3 changes: 3 additions & 0 deletions build/yamls/base/agent-rbac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,13 @@ rules:
- crd.antrea.io
resources:
- egresses
- egresses/status
verbs:
- get
- watch
- list
- update
- patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
11 changes: 11 additions & 0 deletions build/yamls/base/crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ spec:
- format: ipv6
externalIPPool:
type: string
status:
type: object
properties:
nodeName:
type: string
additionalPrinterColumns:
- description: Specifies the SNAT IP address for the selected workloads.
jsonPath: .spec.egressIP
Expand All @@ -89,6 +94,12 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- description: The Owner Node of egress IP
jsonPath: .status.nodeName
name: Status
type: string
subresources:
status: {}
scope: Cluster
names:
plural: egresses
Expand Down
12 changes: 11 additions & 1 deletion cmd/antrea-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"antrea.io/antrea/pkg/agent/flowexporter/exporter"
"antrea.io/antrea/pkg/agent/flowexporter/flowrecords"
"antrea.io/antrea/pkg/agent/interfacestore"
"antrea.io/antrea/pkg/agent/memberlist"
"antrea.io/antrea/pkg/agent/metrics"
npl "antrea.io/antrea/pkg/agent/nodeportlocal"
"antrea.io/antrea/pkg/agent/openflow"
Expand Down Expand Up @@ -77,6 +78,8 @@ func run(o *Options) error {
crdInformerFactory := crdinformers.NewSharedInformerFactory(crdClient, informerDefaultResync)
traceflowInformer := crdInformerFactory.Crd().V1alpha1().Traceflows()
egressInformer := crdInformerFactory.Crd().V1alpha2().Egresses()
nodeInformer := informerFactory.Core().V1().Nodes()
ipPoolInformer := crdInformerFactory.Crd().V1alpha2().ExternalIPPools()

// Create Antrea Clientset for the given config.
antreaClientProvider := agent.NewAntreaClientProvider(o.config.AntreaClientConnection, k8sClient)
Expand Down Expand Up @@ -223,7 +226,14 @@ func run(o *Options) error {

var egressController *egress.EgressController
if features.DefaultFeatureGate.Enabled(features.Egress) {
egressController = egress.NewEgressController(ofClient, egressInformer, antreaClientProvider, ifaceStore, routeClient, nodeConfig.Name)
cluster, err := memberlist.NewCluster(o.config.ClusterPort, nodeInformer, nodeConfig, ipPoolInformer)
if err != nil {
return fmt.Errorf("initializing egress node memberlist cluster failed:%v", err)
}
egressController = egress.NewEgressController(
ofClient, egressInformer, antreaClientProvider, ifaceStore, routeClient, nodeConfig.Name,
cluster,
)
}

isChaining := false
Expand Down
5 changes: 5 additions & 0 deletions cmd/antrea-agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ type AgentConfig struct {
// APIPort is the port for the antrea-agent APIServer to serve on.
// Defaults to 10350.
APIPort int `yaml:"apiPort,omitempty"`

// ClusterPort is the port for the antrea-agent cluster to serve on.
// Defaults to 10351.
ClusterPort int `yaml:"clusterPort,omitempty"`

// Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener
// Defaults to true.
EnablePrometheusMetrics bool `yaml:"enablePrometheusMetrics,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions cmd/antrea-agent/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ func (o *Options) setDefaults() {
o.config.APIPort = apis.AntreaAgentAPIPort
}

if o.config.ClusterPort == 0 {
o.config.ClusterPort = apis.AntreaAgentClusterPort
}

if features.DefaultFeatureGate.Enabled(features.FlowExporter) {
if o.config.FlowCollectorAddr == "" {
o.config.FlowCollectorAddr = defaultFlowCollectorAddress
Expand Down
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ require (
github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1 // indirect
github.com/go-openapi/spec v0.19.5
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.5.0
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.0
github.com/google/uuid v1.1.2
github.com/hashicorp/memberlist v0.2.4
github.com/k8snetworkplumbingwg/sriov-cni v2.1.0+incompatible
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
Expand All @@ -45,10 +47,10 @@ require (
github.com/vmware/go-ipfix v0.5.2
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6
golang.org/x/mod v0.4.0
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073
golang.org/x/mod v0.4.2
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210510120138-977fb7262007
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
google.golang.org/grpc v1.27.1
gopkg.in/natefinch/lumberjack.v2 v2.0.0
Expand Down
Loading