Skip to content

Commit 434ec6b

Browse files
committed
Evolve AntreaProxy with framework and feature updates
This commit brings AntreaProxy: - Add `serviceProxyHealthy` field to Service health check response in AntreaProxy. - Add healthz server serving on port 10256 to AntreaProxy, which is a replacement of kube-proxy health server serving on 10256. - Add support of feature gate PreferSameTrafficDistribution in AntreaProxy. Refer to this https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/3015-prefer-same-node. - Remove Endpoints API support in AntreaProxy. - Align the code `third_party/proxy` with K8s 1.33.1. Signed-off-by: Hongliang Liu <[email protected]>
1 parent bf039b9 commit 434ec6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3538
-3587
lines changed

build/charts/antrea/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Kubernetes: `>= 1.23.0-0`
6161
| antreaProxy.nodePortAddresses | list | `[]` | String array of values which specifies the host IPv4/IPv6 addresses for NodePort. By default, all host addresses are used. |
6262
| antreaProxy.proxyAll | bool | `false` | Proxy all Service traffic, for all Service types, regardless of where it comes from. |
6363
| antreaProxy.proxyLoadBalancerIPs | bool | `true` | When set to false, AntreaProxy no longer load-balances traffic destined to the External IPs of LoadBalancer Services. |
64+
| antreaProxy.serviceHealthCheckServerBindAddress | string | `""` | The value of the IP address and the port on which AntreaProxy health server listens when proxyAll is enabled. This server is functionally equivalent to the one of kube-proxy. If it is not specified, it will be automatically set to "0.0.0.0:10256". |
6465
| antreaProxy.serviceProxyName | string | `""` | The value of the "service.kubernetes.io/service-proxy-name" label for AntreaProxy to match. If it is set, then AntreaProxy will only handle Services with the label that equals the provided value. If it is not set, then AntreaProxy will only handle Services without the "service.kubernetes.io/service-proxy-name" label, but ignore Services with the label no matter what is the value. |
6566
| antreaProxy.skipServices | list | `[]` | List of Services which should be ignored by AntreaProxy. |
6667
| auditLogging.compress | bool | `true` | Compress enables gzip compression on rotated files. |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ 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.
11+
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "PreferSameTrafficDistribution" "default" false) }}
12+
913
# Enable support for cleaning up stale UDP Service conntrack connections in AntreaProxy. This requires AntreaProxy to
1014
# be enabled, otherwise this flag will not take effect.
1115
{{- include "featureGate" (dict "featureGates" .Values.featureGates "name" "CleanupStaleUDPSvcConntrack" "default" true) }}
@@ -427,6 +431,11 @@ antreaProxy:
427431
# enabled. This avoids race conditions between kube-proxy and Antrea Proxy, with both trying to
428432
# bind to the same address, when proxyAll is enabled while kube-proxy has not been removed.
429433
disableServiceHealthCheckServer: {{ .disableServiceHealthCheckServer }}
434+
# The value of the IP address and the port on which AntreaProxy health server listens when proxyAll is enabled. This
435+
# server is functionally equivalent to the one of kube-proxy. If it is not specified, it will be automatically set
436+
# to "0.0.0.0:10256".
437+
serviceHealthCheckServerBindAddress: {{ .serviceHealthCheckServerBindAddress | quote }}
438+
430439
{{- end }}
431440

432441
# IPsec tunnel related configurations.

build/charts/antrea/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ antreaProxy:
165165
# and Antrea Proxy, with both trying to bind to the same address, when proxyAll
166166
# is enabled while kube-proxy has not been removed.
167167
disableServiceHealthCheckServer: false
168+
# -- The value of the IP address and the port on which AntreaProxy health server listens when proxyAll is enabled. This
169+
# server is functionally equivalent to the one of kube-proxy. If it is not specified, it will be automatically set
170+
# to "0.0.0.0:10256".
171+
serviceHealthCheckServerBindAddress: ""
168172

169173
nodeIPAM:
170174
# -- Enable Node IPAM in Antrea

cmd/antrea-agent/agent.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,6 @@ func run(o *Options) error {
454454
var proxyServer *proxy.ProxyServer
455455
if o.enableAntreaProxy {
456456
proxyServer, err = proxy.NewProxyServer(nodeConfig.Name,
457-
k8sClient,
458-
serviceInformer,
459-
endpointsInformer,
460-
endpointSliceInformer,
461-
nodeInformer,
462457
ofClient,
463458
routeClient,
464459
nodeIPTracker,
@@ -474,6 +469,7 @@ func run(o *Options) error {
474469
if err != nil {
475470
return fmt.Errorf("error when creating proxyServer: %v", err)
476471
}
472+
proxyServer.Initialize(ctx, serviceInformer, endpointSliceInformer, nodeInformer)
477473
}
478474

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

cmd/antrea-agent/options.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@ func (o *Options) validateAntreaProxyConfig(encapMode config.TrafficEncapModeTyp
260260
return fmt.Errorf("invalid NodePort IP address `%s`: %w", nodePortAddress, err)
261261
}
262262
}
263+
264+
if addr := o.config.AntreaProxy.ServiceHealthCheckServerBindAddress; addr != "" {
265+
hostStr, portStr, err := net.SplitHostPort(addr)
266+
if err != nil {
267+
return fmt.Errorf("invalid health server bind address %q: %v", addr, err)
268+
}
269+
if net.ParseIP(hostStr) == nil {
270+
return fmt.Errorf("invalid IP address in health server bind address: %q", hostStr)
271+
}
272+
if err := validation.ValidatePortString(portStr); err != nil {
273+
return fmt.Errorf("invalid port in health server bind address: %q: %v", portStr, err)
274+
}
275+
}
263276
}
264277

265278
ok, defaultLoadBalancerMode := config.GetLoadBalancerModeFromStr(o.config.AntreaProxy.DefaultLoadBalancerMode)

cmd/antrea-agent/options_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,28 @@ func TestOptionsValidateAntreaProxyConfig(t *testing.T) {
136136
},
137137
expectedErr: "LoadBalancerMode drs is unknown",
138138
},
139+
{
140+
name: "invalid IP in ServiceHealthCheckServerBindAddress",
141+
trafficEncapMode: config.TrafficEncapModeEncap,
142+
antreaProxyConfig: agentconfig.AntreaProxyConfig{
143+
Enable: ptr.To(true),
144+
DefaultLoadBalancerMode: config.LoadBalancerModeNAT.String(),
145+
ProxyAll: true,
146+
ServiceHealthCheckServerBindAddress: "1.1.1.1.1:10256",
147+
},
148+
expectedErr: "invalid IP address in health server bind address: \"1.1.1.1.1\"",
149+
},
150+
{
151+
name: "invalid port in ServiceHealthCheckServerBindAddress",
152+
trafficEncapMode: config.TrafficEncapModeEncap,
153+
antreaProxyConfig: agentconfig.AntreaProxyConfig{
154+
Enable: ptr.To(true),
155+
DefaultLoadBalancerMode: config.LoadBalancerModeNAT.String(),
156+
ProxyAll: true,
157+
ServiceHealthCheckServerBindAddress: "1.1.1.1:102561",
158+
},
159+
expectedErr: "invalid port in health server bind address: \"102561\": port 102561 is out of range, valid range is 1-65535",
160+
},
139161
}
140162
for _, tt := range tests {
141163
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)