mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #120354 from aroradaman/proxy-conntrack-api
Add support for `nf_conntrack_tcp_be_liberal` sysctl to kube-proxy
This commit is contained in:
commit
5d03ce7ae4
@ -39,6 +39,8 @@ type Conntracker interface {
|
|||||||
SetTCPEstablishedTimeout(seconds int) error
|
SetTCPEstablishedTimeout(seconds int) error
|
||||||
// SetTCPCloseWaitTimeout adjusts nf_conntrack_tcp_timeout_close_wait.
|
// SetTCPCloseWaitTimeout adjusts nf_conntrack_tcp_timeout_close_wait.
|
||||||
SetTCPCloseWaitTimeout(seconds int) error
|
SetTCPCloseWaitTimeout(seconds int) error
|
||||||
|
// SetTCPBeLiberal adjusts nf_conntrack_tcp_be_liberal.
|
||||||
|
SetTCPBeLiberal(value int) error
|
||||||
// SetUDPTimeout adjusts nf_conntrack_udp_timeout.
|
// SetUDPTimeout adjusts nf_conntrack_udp_timeout.
|
||||||
SetUDPTimeout(seconds int) error
|
SetUDPTimeout(seconds int) error
|
||||||
// SetUDPStreamTimeout adjusts nf_conntrack_udp_timeout_stream.
|
// SetUDPStreamTimeout adjusts nf_conntrack_udp_timeout_stream.
|
||||||
@ -96,6 +98,10 @@ func (rct realConntracker) SetTCPCloseWaitTimeout(seconds int) error {
|
|||||||
return rct.setIntSysCtl("nf_conntrack_tcp_timeout_close_wait", seconds)
|
return rct.setIntSysCtl("nf_conntrack_tcp_timeout_close_wait", seconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rct realConntracker) SetTCPBeLiberal(value int) error {
|
||||||
|
return rct.setIntSysCtl("nf_conntrack_tcp_be_liberal", value)
|
||||||
|
}
|
||||||
|
|
||||||
func (rct realConntracker) SetUDPTimeout(seconds int) error {
|
func (rct realConntracker) SetUDPTimeout(seconds int) error {
|
||||||
return rct.setIntSysCtl("nf_conntrack_udp_timeout", seconds)
|
return rct.setIntSysCtl("nf_conntrack_udp_timeout", seconds)
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
|
|||||||
&o.config.Conntrack.TCPCloseWaitTimeout.Duration, "conntrack-tcp-timeout-close-wait",
|
&o.config.Conntrack.TCPCloseWaitTimeout.Duration, "conntrack-tcp-timeout-close-wait",
|
||||||
o.config.Conntrack.TCPCloseWaitTimeout.Duration,
|
o.config.Conntrack.TCPCloseWaitTimeout.Duration,
|
||||||
"NAT timeout for TCP connections in the CLOSE_WAIT state")
|
"NAT timeout for TCP connections in the CLOSE_WAIT state")
|
||||||
|
fs.BoolVar(&o.config.Conntrack.TCPBeLiberal, "conntrack-tcp-be-liberal", o.config.Conntrack.TCPBeLiberal, "Enable liberal mode for tracking TCP packets by setting nf_conntrack_tcp_be_liberal to 1")
|
||||||
fs.DurationVar(&o.config.Conntrack.UDPTimeout.Duration, "conntrack-udp-timeout", o.config.Conntrack.UDPTimeout.Duration, "Idle timeout for UNREPLIED UDP connections (0 to leave as-is)")
|
fs.DurationVar(&o.config.Conntrack.UDPTimeout.Duration, "conntrack-udp-timeout", o.config.Conntrack.UDPTimeout.Duration, "Idle timeout for UNREPLIED UDP connections (0 to leave as-is)")
|
||||||
fs.DurationVar(&o.config.Conntrack.UDPStreamTimeout.Duration, "conntrack-udp-timeout-stream", o.config.Conntrack.UDPStreamTimeout.Duration, "Idle timeout for ASSURED UDP connections (0 to leave as-is)")
|
fs.DurationVar(&o.config.Conntrack.UDPStreamTimeout.Duration, "conntrack-udp-timeout-stream", o.config.Conntrack.UDPStreamTimeout.Duration, "Idle timeout for ASSURED UDP connections (0 to leave as-is)")
|
||||||
|
|
||||||
|
@ -333,6 +333,12 @@ func (s *ProxyServer) setupConntrack() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.Config.Conntrack.TCPBeLiberal {
|
||||||
|
if err := ct.SetTCPBeLiberal(1); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if s.Config.Conntrack.UDPTimeout.Duration > 0 {
|
if s.Config.Conntrack.UDPTimeout.Duration > 0 {
|
||||||
timeout := int(s.Config.Conntrack.UDPTimeout.Duration / time.Second)
|
timeout := int(s.Config.Conntrack.UDPTimeout.Duration / time.Second)
|
||||||
if err := ct.SetUDPTimeout(timeout); err != nil {
|
if err := ct.SetUDPTimeout(timeout); err != nil {
|
||||||
|
10
pkg/generated/openapi/zz_generated.openapi.go
generated
10
pkg/generated/openapi/zz_generated.openapi.go
generated
@ -54358,6 +54358,14 @@ func schema_k8sio_kube_proxy_config_v1alpha1_KubeProxyConntrackConfiguration(ref
|
|||||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"),
|
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"tcpBeLiberal": {
|
||||||
|
SchemaProps: spec.SchemaProps{
|
||||||
|
Description: "tcpBeLiberal, if true, kube-proxy will configure conntrack to run in liberal mode for TCP connections and packets with out-of-window sequence numbers won't be marked INVALID.",
|
||||||
|
Default: false,
|
||||||
|
Type: []string{"boolean"},
|
||||||
|
Format: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
"udpTimeout": {
|
"udpTimeout": {
|
||||||
SchemaProps: spec.SchemaProps{
|
SchemaProps: spec.SchemaProps{
|
||||||
Description: "udpTimeout is how long an idle UDP conntrack entry in UNREPLIED state will remain in the conntrack table (e.g. '30s'). Must be greater than 0 to set.",
|
Description: "udpTimeout is how long an idle UDP conntrack entry in UNREPLIED state will remain in the conntrack table (e.g. '30s'). Must be greater than 0 to set.",
|
||||||
@ -54371,7 +54379,7 @@ func schema_k8sio_kube_proxy_config_v1alpha1_KubeProxyConntrackConfiguration(ref
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Required: []string{"maxPerCore", "min", "tcpEstablishedTimeout", "tcpCloseWaitTimeout", "udpTimeout", "udpStreamTimeout"},
|
Required: []string{"maxPerCore", "min", "tcpEstablishedTimeout", "tcpCloseWaitTimeout", "tcpBeLiberal", "udpTimeout", "udpStreamTimeout"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Dependencies: []string{
|
Dependencies: []string{
|
||||||
|
@ -12,6 +12,7 @@ configSyncPeriod: 15m0s
|
|||||||
conntrack:
|
conntrack:
|
||||||
maxPerCore: 32768
|
maxPerCore: 32768
|
||||||
min: 131072
|
min: 131072
|
||||||
|
tcpBeLiberal: false
|
||||||
tcpCloseWaitTimeout: 1h0m0s
|
tcpCloseWaitTimeout: 1h0m0s
|
||||||
tcpEstablishedTimeout: 24h0m0s
|
tcpEstablishedTimeout: 24h0m0s
|
||||||
udpStreamTimeout: 0s
|
udpStreamTimeout: 0s
|
||||||
|
@ -12,6 +12,7 @@ configSyncPeriod: 15m0s
|
|||||||
conntrack:
|
conntrack:
|
||||||
maxPerCore: 32768
|
maxPerCore: 32768
|
||||||
min: 131072
|
min: 131072
|
||||||
|
tcpBeLiberal: false
|
||||||
tcpCloseWaitTimeout: 1h0m0s
|
tcpCloseWaitTimeout: 1h0m0s
|
||||||
tcpEstablishedTimeout: 24h0m0s
|
tcpEstablishedTimeout: 24h0m0s
|
||||||
udpStreamTimeout: 0s
|
udpStreamTimeout: 0s
|
||||||
|
@ -97,6 +97,10 @@ type KubeProxyConntrackConfiguration struct {
|
|||||||
// in CLOSE_WAIT state will remain in the conntrack
|
// in CLOSE_WAIT state will remain in the conntrack
|
||||||
// table. (e.g. '60s'). Must be greater than 0 to set.
|
// table. (e.g. '60s'). Must be greater than 0 to set.
|
||||||
TCPCloseWaitTimeout *metav1.Duration
|
TCPCloseWaitTimeout *metav1.Duration
|
||||||
|
// tcpBeLiberal, if true, kube-proxy will configure conntrack
|
||||||
|
// to run in liberal mode for TCP connections and packets with
|
||||||
|
// out-of-window sequence numbers won't be marked INVALID.
|
||||||
|
TCPBeLiberal bool
|
||||||
// udpTimeout is how long an idle UDP conntrack entry in
|
// udpTimeout is how long an idle UDP conntrack entry in
|
||||||
// UNREPLIED state will remain in the conntrack table
|
// UNREPLIED state will remain in the conntrack table
|
||||||
// (e.g. '30s'). Must be greater than 0 to set.
|
// (e.g. '30s'). Must be greater than 0 to set.
|
||||||
|
@ -215,6 +215,7 @@ func autoConvert_v1alpha1_KubeProxyConntrackConfiguration_To_config_KubeProxyCon
|
|||||||
out.Min = (*int32)(unsafe.Pointer(in.Min))
|
out.Min = (*int32)(unsafe.Pointer(in.Min))
|
||||||
out.TCPEstablishedTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPEstablishedTimeout))
|
out.TCPEstablishedTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPEstablishedTimeout))
|
||||||
out.TCPCloseWaitTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPCloseWaitTimeout))
|
out.TCPCloseWaitTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPCloseWaitTimeout))
|
||||||
|
out.TCPBeLiberal = in.TCPBeLiberal
|
||||||
out.UDPTimeout = in.UDPTimeout
|
out.UDPTimeout = in.UDPTimeout
|
||||||
out.UDPStreamTimeout = in.UDPStreamTimeout
|
out.UDPStreamTimeout = in.UDPStreamTimeout
|
||||||
return nil
|
return nil
|
||||||
@ -230,6 +231,7 @@ func autoConvert_config_KubeProxyConntrackConfiguration_To_v1alpha1_KubeProxyCon
|
|||||||
out.Min = (*int32)(unsafe.Pointer(in.Min))
|
out.Min = (*int32)(unsafe.Pointer(in.Min))
|
||||||
out.TCPEstablishedTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPEstablishedTimeout))
|
out.TCPEstablishedTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPEstablishedTimeout))
|
||||||
out.TCPCloseWaitTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPCloseWaitTimeout))
|
out.TCPCloseWaitTimeout = (*v1.Duration)(unsafe.Pointer(in.TCPCloseWaitTimeout))
|
||||||
|
out.TCPBeLiberal = in.TCPBeLiberal
|
||||||
out.UDPTimeout = in.UDPTimeout
|
out.UDPTimeout = in.UDPTimeout
|
||||||
out.UDPStreamTimeout = in.UDPStreamTimeout
|
out.UDPStreamTimeout = in.UDPStreamTimeout
|
||||||
return nil
|
return nil
|
||||||
|
@ -93,6 +93,10 @@ type KubeProxyConntrackConfiguration struct {
|
|||||||
// in CLOSE_WAIT state will remain in the conntrack
|
// in CLOSE_WAIT state will remain in the conntrack
|
||||||
// table. (e.g. '60s'). Must be greater than 0 to set.
|
// table. (e.g. '60s'). Must be greater than 0 to set.
|
||||||
TCPCloseWaitTimeout *metav1.Duration `json:"tcpCloseWaitTimeout"`
|
TCPCloseWaitTimeout *metav1.Duration `json:"tcpCloseWaitTimeout"`
|
||||||
|
// tcpBeLiberal, if true, kube-proxy will configure conntrack
|
||||||
|
// to run in liberal mode for TCP connections and packets with
|
||||||
|
// out-of-window sequence numbers won't be marked INVALID.
|
||||||
|
TCPBeLiberal bool `json:"tcpBeLiberal"`
|
||||||
// udpTimeout is how long an idle UDP conntrack entry in
|
// udpTimeout is how long an idle UDP conntrack entry in
|
||||||
// UNREPLIED state will remain in the conntrack table
|
// UNREPLIED state will remain in the conntrack table
|
||||||
// (e.g. '30s'). Must be greater than 0 to set.
|
// (e.g. '30s'). Must be greater than 0 to set.
|
||||||
|
Loading…
Reference in New Issue
Block a user