Skip to content

Commit c37ec22

Browse files
committed
Use K8s upstream NodeManager
Signed-off-by: Hongliang Liu <[email protected]>
1 parent 19e8fa9 commit c37ec22

File tree

21 files changed

+442
-140
lines changed

21 files changed

+442
-140
lines changed

build/charts/antrea/conf/antrea-agent.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ featureGates:
66
# AllBeta is a global toggle for beta features. Per-feature key values override the default set by AllBeta.
77
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "AllBeta" "default" false) }}
88

9-
# Enable PreferSameTrafficDistribution in AntreaProxy, allowing usage of the values PreferSameZone and PreferSameNode in
10-
# the Service trafficDistribution field.
9+
# Enable PreferSameTrafficDistribution so that AntreaProxy can honor the Service's trafficDistribution settings
10+
# (PreferSameZone / PreferSameNode) when selecting backend Pods.
1111
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "PreferSameTrafficDistribution" "default" false) }}
1212

1313
# Enable support for cleaning up stale UDP Service conntrack connections in AntreaProxy. This requires AntreaProxy to

build/yamls/antrea-aks.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4219,8 +4219,8 @@ data:
42194219
# AllBeta is a global toggle for beta features. Per-feature key values override the default set by AllBeta.
42204220
# AllBeta: false
42214221
4222-
# Enable PreferSameTrafficDistribution in AntreaProxy, allowing usage of the values PreferSameZone and PreferSameNode in
4223-
# the Service trafficDistribution field.
4222+
# Enable PreferSameTrafficDistribution so that AntreaProxy can honor the Service's trafficDistribution settings
4223+
# (PreferSameZone / PreferSameNode) when selecting backend Pods.
42244224
# PreferSameTrafficDistribution: false
42254225
42264226
# Enable support for cleaning up stale UDP Service conntrack connections in AntreaProxy. This requires AntreaProxy to
@@ -5721,7 +5721,7 @@ spec:
57215721
kubectl.kubernetes.io/default-container: antrea-agent
57225722
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
57235723
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5724-
checksum/config: 7bcd8deb7017b8f37297525634f5cf700d2e5832342e4fa80c05ab627dedfa83
5724+
checksum/config: 7164c2236357aab9edb1267ae3a6d8abdf7a4be1f60c444101f4012376d98172
57255725
labels:
57265726
app: antrea
57275727
component: antrea-agent
@@ -5969,7 +5969,7 @@ spec:
59695969
annotations:
59705970
# Automatically restart Pod if the ConfigMap changes
59715971
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5972-
checksum/config: 7bcd8deb7017b8f37297525634f5cf700d2e5832342e4fa80c05ab627dedfa83
5972+
checksum/config: 7164c2236357aab9edb1267ae3a6d8abdf7a4be1f60c444101f4012376d98172
59735973
labels:
59745974
app: antrea
59755975
component: antrea-controller

build/yamls/antrea-eks.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,8 +4215,8 @@ data:
42154215
# AllBeta is a global toggle for beta features. Per-feature key values override the default set by AllBeta.
42164216
# AllBeta: false
42174217
4218-
# Enable PreferSameTrafficDistribution in AntreaProxy, allowing usage of the values PreferSameZone and PreferSameNode in
4219-
# the Service trafficDistribution field.
4218+
# Enable PreferSameTrafficDistribution so that AntreaProxy can honor the Service's trafficDistribution settings
4219+
# (PreferSameZone / PreferSameNode) when selecting backend Pods.
42204220
# PreferSameTrafficDistribution: false
42214221
42224222
# Enable support for cleaning up stale UDP Service conntrack connections in AntreaProxy. This requires AntreaProxy to
@@ -5717,7 +5717,7 @@ spec:
57175717
kubectl.kubernetes.io/default-container: antrea-agent
57185718
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
57195719
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5720-
checksum/config: 7bcd8deb7017b8f37297525634f5cf700d2e5832342e4fa80c05ab627dedfa83
5720+
checksum/config: 7164c2236357aab9edb1267ae3a6d8abdf7a4be1f60c444101f4012376d98172
57215721
labels:
57225722
app: antrea
57235723
component: antrea-agent
@@ -5966,7 +5966,7 @@ spec:
59665966
annotations:
59675967
# Automatically restart Pod if the ConfigMap changes
59685968
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5969-
checksum/config: 7bcd8deb7017b8f37297525634f5cf700d2e5832342e4fa80c05ab627dedfa83
5969+
checksum/config: 7164c2236357aab9edb1267ae3a6d8abdf7a4be1f60c444101f4012376d98172
59705970
labels:
59715971
app: antrea
59725972
component: antrea-controller

build/yamls/antrea-gke.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,8 +4215,8 @@ data:
42154215
# AllBeta is a global toggle for beta features. Per-feature key values override the default set by AllBeta.
42164216
# AllBeta: false
42174217
4218-
# Enable PreferSameTrafficDistribution in AntreaProxy, allowing usage of the values PreferSameZone and PreferSameNode in
4219-
# the Service trafficDistribution field.
4218+
# Enable PreferSameTrafficDistribution so that AntreaProxy can honor the Service's trafficDistribution settings
4219+
# (PreferSameZone / PreferSameNode) when selecting backend Pods.
42204220
# PreferSameTrafficDistribution: false
42214221
42224222
# Enable support for cleaning up stale UDP Service conntrack connections in AntreaProxy. This requires AntreaProxy to
@@ -5708,7 +5708,7 @@ spec:
57085708
kubectl.kubernetes.io/default-container: antrea-agent
57095709
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
57105710
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5711-
checksum/config: f0a7ae5dcf068ffe8fae6e260174a2778e4def5f77b3d4f11af3a59843b17842
5711+
checksum/config: bf5a6fee5b84edc0803d6bf0965a411f3d88f64776ebfe30a8924baa9dc8c5da
57125712
labels:
57135713
app: antrea
57145714
component: antrea-agent
@@ -5954,7 +5954,7 @@ spec:
59545954
annotations:
59555955
# Automatically restart Pod if the ConfigMap changes
59565956
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5957-
checksum/config: f0a7ae5dcf068ffe8fae6e260174a2778e4def5f77b3d4f11af3a59843b17842
5957+
checksum/config: bf5a6fee5b84edc0803d6bf0965a411f3d88f64776ebfe30a8924baa9dc8c5da
59585958
labels:
59595959
app: antrea
59605960
component: antrea-controller

build/yamls/antrea-ipsec.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4228,8 +4228,8 @@ data:
42284228
# AllBeta is a global toggle for beta features. Per-feature key values override the default set by AllBeta.
42294229
# AllBeta: false
42304230
4231-
# Enable PreferSameTrafficDistribution in AntreaProxy, allowing usage of the values PreferSameZone and PreferSameNode in
4232-
# the Service trafficDistribution field.
4231+
# Enable PreferSameTrafficDistribution so that AntreaProxy can honor the Service's trafficDistribution settings
4232+
# (PreferSameZone / PreferSameNode) when selecting backend Pods.
42334233
# PreferSameTrafficDistribution: false
42344234
42354235
# Enable support for cleaning up stale UDP Service conntrack connections in AntreaProxy. This requires AntreaProxy to
@@ -5721,7 +5721,7 @@ spec:
57215721
kubectl.kubernetes.io/default-container: antrea-agent
57225722
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
57235723
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5724-
checksum/config: a97393291137add4c34e6b6f840bdab5584837131bcac0e8fcd15be684e6d85d
5724+
checksum/config: df497006c72465290efa91e3abc8ce6169b087a6a7ddc2bacda4aecab200a774
57255725
checksum/ipsec-secret: d0eb9c52d0cd4311b6d252a951126bf9bea27ec05590bed8a394f0f792dcb2a4
57265726
labels:
57275727
app: antrea
@@ -6013,7 +6013,7 @@ spec:
60136013
annotations:
60146014
# Automatically restart Pod if the ConfigMap changes
60156015
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
6016-
checksum/config: a97393291137add4c34e6b6f840bdab5584837131bcac0e8fcd15be684e6d85d
6016+
checksum/config: df497006c72465290efa91e3abc8ce6169b087a6a7ddc2bacda4aecab200a774
60176017
labels:
60186018
app: antrea
60196019
component: antrea-controller

build/yamls/antrea.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4215,8 +4215,8 @@ data:
42154215
# AllBeta is a global toggle for beta features. Per-feature key values override the default set by AllBeta.
42164216
# AllBeta: false
42174217
4218-
# Enable PreferSameTrafficDistribution in AntreaProxy, allowing usage of the values PreferSameZone and PreferSameNode in
4219-
# the Service trafficDistribution field.
4218+
# Enable PreferSameTrafficDistribution so that AntreaProxy can honor the Service's trafficDistribution settings
4219+
# (PreferSameZone / PreferSameNode) when selecting backend Pods.
42204220
# PreferSameTrafficDistribution: false
42214221
42224222
# Enable support for cleaning up stale UDP Service conntrack connections in AntreaProxy. This requires AntreaProxy to
@@ -5708,7 +5708,7 @@ spec:
57085708
kubectl.kubernetes.io/default-container: antrea-agent
57095709
# Automatically restart Pods with a RollingUpdate if the ConfigMap changes
57105710
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5711-
checksum/config: cea980c8e36a19ce1e4c4f4977786aced6a90cc193a2eed8d0a996612fd84ff7
5711+
checksum/config: d30e0a917e8224438e4772d6a2b79a9e993b01c077bc1f75eeb7df9a5d8eeb8f
57125712
labels:
57135713
app: antrea
57145714
component: antrea-agent
@@ -5954,7 +5954,7 @@ spec:
59545954
annotations:
59555955
# Automatically restart Pod if the ConfigMap changes
59565956
# See https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments
5957-
checksum/config: cea980c8e36a19ce1e4c4f4977786aced6a90cc193a2eed8d0a996612fd84ff7
5957+
checksum/config: d30e0a917e8224438e4772d6a2b79a9e993b01c077bc1f75eeb7df9a5d8eeb8f
59585958
labels:
59595959
app: antrea
59605960
component: antrea-controller

cmd/antrea-agent/agent.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import (
8989
"antrea.io/antrea/pkg/util/objectstore"
9090
utilwait "antrea.io/antrea/pkg/util/wait"
9191
"antrea.io/antrea/pkg/version"
92+
k8sproxy "antrea.io/antrea/third_party/proxy"
9293
)
9394

9495
// informerDefaultResync is the default resync period if a handler doesn't specify one.
@@ -451,9 +452,14 @@ func run(o *Options) error {
451452
groupCounters = append(groupCounters, v6GroupCounter)
452453
}
453454

455+
nodeManager, err := k8sproxy.NewNodeManager(ctx, k8sClient, resyncPeriodDisabled, nodeConfig.Name, false)
456+
if err != nil {
457+
return fmt.Errorf("failed to create node manager: %w", err)
458+
}
454459
var proxyServer *proxy.ProxyServer
455460
if o.enableAntreaProxy {
456461
proxyServer, err = proxy.NewProxyServer(nodeConfig.Name,
462+
nodeManager,
457463
ofClient,
458464
routeClient,
459465
nodeIPTracker,
@@ -467,9 +473,9 @@ func run(o *Options) error {
467473
v6GroupCounter,
468474
enableMulticlusterGW)
469475
if err != nil {
470-
return fmt.Errorf("error when creating proxyServer: %v", err)
476+
return fmt.Errorf("error when creating proxyServer: %w", err)
471477
}
472-
proxyServer.Initialize(ctx, serviceInformer, endpointSliceInformer, nodeInformer)
478+
proxyServer.Initialize(ctx, serviceInformer, endpointSliceInformer)
473479
}
474480

475481
// We pick a time interval for rule deletion in the async rule cache (part of the

cmd/antrea-agent/options.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,13 @@ func (o *Options) validateAntreaProxyConfig(encapMode config.TrafficEncapModeTyp
264264
if addr := o.config.AntreaProxy.ServiceHealthCheckServerBindAddress; addr != "" {
265265
hostStr, portStr, err := net.SplitHostPort(addr)
266266
if err != nil {
267-
return fmt.Errorf("invalid health server bind address %q: %v", addr, err)
267+
return fmt.Errorf("invalid health server bind address %q: %w", addr, err)
268268
}
269269
if net.ParseIP(hostStr) == nil {
270270
return fmt.Errorf("invalid IP address in health server bind address: %q", hostStr)
271271
}
272272
if err := validation.ValidatePortString(portStr); err != nil {
273-
return fmt.Errorf("invalid port in health server bind address: %q: %v", portStr, err)
273+
return fmt.Errorf("invalid port in health server bind address: %q: %w", portStr, err)
274274
}
275275
}
276276
}
@@ -449,6 +449,9 @@ func (o *Options) setK8sNodeDefaultOptions() {
449449
if o.config.AntreaProxy.ProxyLoadBalancerIPs == nil {
450450
o.config.AntreaProxy.ProxyLoadBalancerIPs = ptr.To(true)
451451
}
452+
if o.config.AntreaProxy.ServiceHealthCheckServerBindAddress == "" {
453+
o.config.AntreaProxy.ServiceHealthCheckServerBindAddress = net.JoinHostPort(net.IPv4zero.String(), fmt.Sprint(apis.AntreaProxyHealthServerPort))
454+
}
452455
if o.config.ServiceCIDR == "" {
453456
//It's okay to set the default value of this field even when AntreaProxy is enabled and the field is not used.
454457
o.config.ServiceCIDR = defaultServiceCIDR

docs/feature-gates.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ edit the Agent configuration in the
3333
| Feature Name | Component | Default | Stage | Alpha Release | Beta Release | GA Release | Extra Requirements | Notes |
3434
|---------------------------------|--------------------|---------|------------|---------------|--------------|------------|--------------------|--------------------------------------------------------|
3535
| `AntreaProxy` | Agent | `true` | GA | v0.8 | v0.11 | v1.14 | Yes | Must be enabled for Windows. |
36-
| `EndpointSlice` | Agent | `true` | GA | v0.13.0 | v1.11 | v1.14 | Yes | |
36+
| `EndpointSlice` | Agent | `true` | GA | v0.13.0 | v1.11 | v1.14 | Yes | Locked to `true` (cannot be disabled). |
3737
| `TopologyAwareHints` | Agent | `true` | GA | v1.8 | v1.12 | v2.5 | Yes | |
3838
| `ServiceTrafficDistribution` | Agent | `true` | GA | N/A | v2.2 | v2.5 | Yes | |
3939
| `PreferSameTrafficDistribution` | Agent | `false` | Alpha | v2.5 | N/A | N/A | Yes | |
@@ -89,6 +89,8 @@ opposed to >= 4.4 without this feature).
8989
`EndpointSlice` enables Service EndpointSlice support in Antrea Proxy. The EndpointSlice API was introduced in Kubernetes
9090
1.16 (alpha) and it is enabled by default in Kubernetes 1.17 (beta), promoted to GA in Kubernetes 1.21.
9191

92+
Starting from Antrea v2.5.0, the feature is locked to `true` and cannot be disabled.
93+
9294
#### Requirements for this Feature
9395

9496
- Option `antreaProxy.enable` is set to true.
@@ -117,9 +119,11 @@ refer to this [link](https://github.com/kubernetes/enhancements/tree/master/keps
117119

118120
### PreferSameTrafficDistribution
119121

120-
`PreferSameTrafficDistribution` allows usage of the values `PreferSameZone` and `PreferSameNode` in the Service
121-
trafficDistribution field in Antrea Proxy. For more details, refer to this
122-
[link](https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/3015-prefer-same-node).
122+
`PreferSameTrafficDistribution` enables AntreaProxy to honor the Service's trafficDistribution settings
123+
(PreferSameZone / PreferSameNode) when selecting backend Pods.
124+
125+
For additional background, see the upstream enhancement proposal:
126+
[KEP 3015 – Prefer Same Node](https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/3015-prefer-same-node).
123127

124128
#### Requirements for this Feature
125129

docs/network-requirements.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ number from the output of `kubectl get svc kubernetes -o yaml`._
2828

2929
[4] _The default value is 10256, but it can be overridden in the antrea-agent
3030
configuration `antreaProxy.serviceHealthCheckServerBindAddress`. It is used only
31-
for external load balancer health checks._
31+
for external load balancer health checks. If `antreaProxy.disableServiceHealthCheckServer`
32+
is set `true`, the health check server listening on the port will be disabled._

0 commit comments

Comments
 (0)