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

Implement the controller for API BGPPolicy #6203

Merged
merged 1 commit into from
Jul 25, 2024
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
4 changes: 4 additions & 0 deletions build/charts/antrea/conf/antrea-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ featureGates:
# Enable NodeLatencyMonitor to monitor the latency between Nodes.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "NodeLatencyMonitor" "default" false) }}

# Allow users to initiate BGP process on selected Kubernetes Nodes and advertise Service IPs, Pod IPs and Egress IPs to
# remote BGP peers.
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "BGPPolicy" "default" false) }}

# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: {{ .Values.ovs.bridgeName | quote }}
Expand Down
11 changes: 11 additions & 0 deletions build/charts/antrea/templates/agent/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ rules:
- apiGroups:
- crd.antrea.io
resources:
- bgppolicies
- externalippools
- ippools
- trafficcontrols
Expand Down Expand Up @@ -234,3 +235,13 @@ rules:
- create
- patch
- update
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- antrea-bgp-passwords
verbs:
- get
- list
- watch
19 changes: 17 additions & 2 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,10 @@ data:
# Enable NodeLatencyMonitor to monitor the latency between Nodes.
# NodeLatencyMonitor: false

# Allow users to initiate BGP process on selected Kubernetes Nodes and advertise Service IPs, Pod IPs and Egress IPs to
# remote BGP peers.
# BGPPolicy: false

# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -4445,6 +4449,7 @@ rules:
- apiGroups:
- crd.antrea.io
resources:
- bgppolicies
- externalippools
- ippools
- trafficcontrols
Expand Down Expand Up @@ -4502,6 +4507,16 @@ rules:
- create
- patch
- update
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- antrea-bgp-passwords
verbs:
- get
- list
- watch
---
# Source: antrea/templates/antctl/clusterrole.yaml
kind: ClusterRole
Expand Down Expand Up @@ -5110,7 +5125,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 71bf05ff579aa9bea7b360669c5e2ce2830ca88dc4ab54480638ce006eaeaf11
checksum/config: cce7d6644fb552607ebeda9bf30a5fafa871dd4382afc609500fcb493b61768c
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -5348,7 +5363,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 71bf05ff579aa9bea7b360669c5e2ce2830ca88dc4ab54480638ce006eaeaf11
checksum/config: cce7d6644fb552607ebeda9bf30a5fafa871dd4382afc609500fcb493b61768c
labels:
app: antrea
component: antrea-controller
Expand Down
19 changes: 17 additions & 2 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,10 @@ data:
# Enable NodeLatencyMonitor to monitor the latency between Nodes.
# NodeLatencyMonitor: false

# Allow users to initiate BGP process on selected Kubernetes Nodes and advertise Service IPs, Pod IPs and Egress IPs to
# remote BGP peers.
# BGPPolicy: false

# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -4445,6 +4449,7 @@ rules:
- apiGroups:
- crd.antrea.io
resources:
- bgppolicies
- externalippools
- ippools
- trafficcontrols
Expand Down Expand Up @@ -4502,6 +4507,16 @@ rules:
- create
- patch
- update
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- antrea-bgp-passwords
verbs:
- get
- list
- watch
---
# Source: antrea/templates/antctl/clusterrole.yaml
kind: ClusterRole
Expand Down Expand Up @@ -5110,7 +5125,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 71bf05ff579aa9bea7b360669c5e2ce2830ca88dc4ab54480638ce006eaeaf11
checksum/config: cce7d6644fb552607ebeda9bf30a5fafa871dd4382afc609500fcb493b61768c
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -5349,7 +5364,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 71bf05ff579aa9bea7b360669c5e2ce2830ca88dc4ab54480638ce006eaeaf11
checksum/config: cce7d6644fb552607ebeda9bf30a5fafa871dd4382afc609500fcb493b61768c
labels:
app: antrea
component: antrea-controller
Expand Down
19 changes: 17 additions & 2 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,10 @@ data:
# Enable NodeLatencyMonitor to monitor the latency between Nodes.
# NodeLatencyMonitor: false

# Allow users to initiate BGP process on selected Kubernetes Nodes and advertise Service IPs, Pod IPs and Egress IPs to
# remote BGP peers.
# BGPPolicy: false

# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -4445,6 +4449,7 @@ rules:
- apiGroups:
- crd.antrea.io
resources:
- bgppolicies
- externalippools
- ippools
- trafficcontrols
Expand Down Expand Up @@ -4502,6 +4507,16 @@ rules:
- create
- patch
- update
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- antrea-bgp-passwords
verbs:
- get
- list
- watch
---
# Source: antrea/templates/antctl/clusterrole.yaml
kind: ClusterRole
Expand Down Expand Up @@ -5110,7 +5125,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 91ff2b609519e4aaead6ab850252a49bbe674dec17f6f239c4d0fa6c7b5705f6
checksum/config: e30c52c9fcb04d362d018e846cf72dc633c5e891e02b3ebb87fab4d7ee08e15a
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -5346,7 +5361,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 91ff2b609519e4aaead6ab850252a49bbe674dec17f6f239c4d0fa6c7b5705f6
checksum/config: e30c52c9fcb04d362d018e846cf72dc633c5e891e02b3ebb87fab4d7ee08e15a
labels:
app: antrea
component: antrea-controller
Expand Down
19 changes: 17 additions & 2 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3820,6 +3820,10 @@ data:
# Enable NodeLatencyMonitor to monitor the latency between Nodes.
# NodeLatencyMonitor: false

# Allow users to initiate BGP process on selected Kubernetes Nodes and advertise Service IPs, Pod IPs and Egress IPs to
# remote BGP peers.
# BGPPolicy: false

# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -4458,6 +4462,7 @@ rules:
- apiGroups:
- crd.antrea.io
resources:
- bgppolicies
- externalippools
- ippools
- trafficcontrols
Expand Down Expand Up @@ -4515,6 +4520,16 @@ rules:
- create
- patch
- update
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- antrea-bgp-passwords
verbs:
- get
- list
- watch
---
# Source: antrea/templates/antctl/clusterrole.yaml
kind: ClusterRole
Expand Down Expand Up @@ -5123,7 +5138,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 2d75956786eb552eaba94f89dfa5c6bab570bf662b82449e9af31a57ca138750
checksum/config: 73a49a9a8508cc8fb94eb2c770bb3589e68d9623327231943cba60a48716568a
checksum/ipsec-secret: d0eb9c52d0cd4311b6d252a951126bf9bea27ec05590bed8a394f0f792dcb2a4
labels:
app: antrea
Expand Down Expand Up @@ -5405,7 +5420,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: 2d75956786eb552eaba94f89dfa5c6bab570bf662b82449e9af31a57ca138750
checksum/config: 73a49a9a8508cc8fb94eb2c770bb3589e68d9623327231943cba60a48716568a
labels:
app: antrea
component: antrea-controller
Expand Down
19 changes: 17 additions & 2 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,10 @@ data:
# Enable NodeLatencyMonitor to monitor the latency between Nodes.
# NodeLatencyMonitor: false

# Allow users to initiate BGP process on selected Kubernetes Nodes and advertise Service IPs, Pod IPs and Egress IPs to
# remote BGP peers.
# BGPPolicy: false

# Name of the OpenVSwitch bridge antrea-agent will create and use.
# Make sure it doesn't conflict with your existing OpenVSwitch bridges.
ovsBridge: "br-int"
Expand Down Expand Up @@ -4445,6 +4449,7 @@ rules:
- apiGroups:
- crd.antrea.io
resources:
- bgppolicies
- externalippools
- ippools
- trafficcontrols
Expand Down Expand Up @@ -4502,6 +4507,16 @@ rules:
- create
- patch
- update
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- antrea-bgp-passwords
verbs:
- get
- list
- watch
---
# Source: antrea/templates/antctl/clusterrole.yaml
kind: ClusterRole
Expand Down Expand Up @@ -5110,7 +5125,7 @@ spec:
kubectl.kubernetes.io/default-container: antrea-agent
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: ebc0be79b0fc65db51609f5c9185ca8a0533e265811d14c687f577cf93497a58
checksum/config: 20130c4a5dbfeec75182bc3053288f64c06d0350b34c86675ac88d5961c47853
labels:
app: antrea
component: antrea-agent
Expand Down Expand Up @@ -5346,7 +5361,7 @@ spec:
annotations:
# Automatically restart Pod if the ConfigMap changes
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
checksum/config: ebc0be79b0fc65db51609f5c9185ca8a0533e265811d14c687f577cf93497a58
checksum/config: 20130c4a5dbfeec75182bc3053288f64c06d0350b34c86675ac88d5961c47853
labels:
app: antrea
component: antrea-controller
Expand Down
18 changes: 18 additions & 0 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/cniserver"
"antrea.io/antrea/pkg/agent/cniserver/ipam"
"antrea.io/antrea/pkg/agent/config"
"antrea.io/antrea/pkg/agent/controller/bgp"
"antrea.io/antrea/pkg/agent/controller/egress"
"antrea.io/antrea/pkg/agent/controller/ipseccertificate"
"antrea.io/antrea/pkg/agent/controller/l7flowexporter"
Expand Down Expand Up @@ -743,6 +744,23 @@ func run(o *Options) error {
}
}

if features.DefaultFeatureGate.Enabled(features.BGPPolicy) {
bgpPolicyInformer := crdInformerFactory.Crd().V1alpha1().BGPPolicies()
bgpController, err := bgp.NewBGPPolicyController(nodeInformer,
serviceInformer,
egressInformer,
bgpPolicyInformer,
endpointSliceInformer,
o.enableEgress,
k8sClient,
nodeConfig,
networkConfig)
if err != nil {
return err
}
go bgpController.Run(ctx)
}

if features.DefaultFeatureGate.Enabled(features.TrafficControl) {
tcController := trafficcontrol.NewTrafficControlController(ofClient,
ifaceStore,
Expand Down
11 changes: 11 additions & 0 deletions docs/feature-gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ edit the Agent configuration in the
| `EgressSeparateSubnet` | Agent | `false` | Alpha | v1.15 | N/A | N/A | No | |
| `NodeNetworkPolicy` | Agent | `false` | Alpha | v1.15 | N/A | N/A | Yes | |
| `L7FlowExporter` | Agent | `false` | Alpha | v1.15 | N/A | N/A | Yes | |
| `BGPPolicy` | Agent | `false` | Alpha | v2.1 | N/A | N/A | No | |

## Description and Requirements of Features

Expand Down Expand Up @@ -435,3 +436,13 @@ Refer to this [document](network-flow-visibility.md#l7-visibility) for more info
#### Requirements for this Feature

- Linux Nodes only.

### BGPPolicy

`BGPPolicy` allows users to initiate BGP process on selected Kubernetes Nodes and advertise Service IPs (e.g.,
ClusterIPs, ExternalIPs, LoadBalancerIPs), Pod IPs and Egress IPs to remote BGP peers, providing a flexible mechanism
for integrating Kubernetes clusters with external BGP-enabled networks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add Refer to this [document](bgp-policy.md) for more information. at the end in this PR, or update in the doc PR after this is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update the doc after this is merged.


#### Requirements for this Feature

- Linux Nodes only.
Loading