mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
Merge pull request #97336 from maaoBit/remove_cleanup-ipvs
remove --cleanup-ipvs flag of kube-proxy
This commit is contained in:
commit
ffe74b2cf1
@ -108,8 +108,6 @@ type Options struct {
|
|||||||
WriteConfigTo string
|
WriteConfigTo string
|
||||||
// CleanupAndExit, when true, makes the proxy server clean up iptables and ipvs rules, then exit.
|
// CleanupAndExit, when true, makes the proxy server clean up iptables and ipvs rules, then exit.
|
||||||
CleanupAndExit bool
|
CleanupAndExit bool
|
||||||
// CleanupIPVS, when true, makes the proxy server clean up ipvs rules before running.
|
|
||||||
CleanupIPVS bool
|
|
||||||
// WindowsService should be set to true if kube-proxy is running as a service on Windows.
|
// WindowsService should be set to true if kube-proxy is running as a service on Windows.
|
||||||
// Its corresponding flag only gets registered in Windows builds
|
// Its corresponding flag only gets registered in Windows builds
|
||||||
WindowsService bool
|
WindowsService bool
|
||||||
@ -162,8 +160,6 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
|
|||||||
"A string slice of values which specify the addresses to use for NodePorts. Values may be valid IP blocks (e.g. 1.2.3.0/24, 1.2.3.4/32). The default empty string slice ([]) means to use all local addresses.")
|
"A string slice of values which specify the addresses to use for NodePorts. Values may be valid IP blocks (e.g. 1.2.3.0/24, 1.2.3.4/32). The default empty string slice ([]) means to use all local addresses.")
|
||||||
|
|
||||||
fs.BoolVar(&o.CleanupAndExit, "cleanup", o.CleanupAndExit, "If true cleanup iptables and ipvs rules and exit.")
|
fs.BoolVar(&o.CleanupAndExit, "cleanup", o.CleanupAndExit, "If true cleanup iptables and ipvs rules and exit.")
|
||||||
fs.BoolVar(&o.CleanupIPVS, "cleanup-ipvs", o.CleanupIPVS, "If true and --cleanup is specified, kube-proxy will also flush IPVS rules, in addition to normal cleanup.")
|
|
||||||
fs.MarkDeprecated("cleanup-ipvs", "In a future release, running --cleanup will always flush IPVS rules")
|
|
||||||
|
|
||||||
fs.Var(utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to '0.0.0.0' for all IPv4 interfaces and '::' for all IPv6 interfaces)")
|
fs.Var(utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to '0.0.0.0' for all IPv4 interfaces and '::' for all IPv6 interfaces)")
|
||||||
fs.Var(utilflag.IPPortVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address with port for the health check server to serve on (set to '0.0.0.0:10256' for all IPv4 interfaces and '[::]:10256' for all IPv6 interfaces). Set empty to disable.")
|
fs.Var(utilflag.IPPortVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address with port for the health check server to serve on (set to '0.0.0.0:10256' for all IPv4 interfaces and '[::]:10256' for all IPv6 interfaces). Set empty to disable.")
|
||||||
@ -215,7 +211,6 @@ func NewOptions() *Options {
|
|||||||
config: new(kubeproxyconfig.KubeProxyConfiguration),
|
config: new(kubeproxyconfig.KubeProxyConfiguration),
|
||||||
healthzPort: ports.ProxyHealthzPort,
|
healthzPort: ports.ProxyHealthzPort,
|
||||||
metricsPort: ports.ProxyStatusPort,
|
metricsPort: ports.ProxyStatusPort,
|
||||||
CleanupIPVS: true,
|
|
||||||
errCh: make(chan error),
|
errCh: make(chan error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -535,7 +530,6 @@ type ProxyServer struct {
|
|||||||
Conntracker Conntracker // if nil, ignored
|
Conntracker Conntracker // if nil, ignored
|
||||||
ProxyMode string
|
ProxyMode string
|
||||||
NodeRef *v1.ObjectReference
|
NodeRef *v1.ObjectReference
|
||||||
CleanupIPVS bool
|
|
||||||
MetricsBindAddress string
|
MetricsBindAddress string
|
||||||
BindAddressHardFail bool
|
BindAddressHardFail bool
|
||||||
EnableProfiling bool
|
EnableProfiling bool
|
||||||
@ -813,7 +807,7 @@ func (s *ProxyServer) CleanupAndExit() error {
|
|||||||
for _, ipt := range ipts {
|
for _, ipt := range ipts {
|
||||||
encounteredError = userspace.CleanupLeftovers(ipt) || encounteredError
|
encounteredError = userspace.CleanupLeftovers(ipt) || encounteredError
|
||||||
encounteredError = iptables.CleanupLeftovers(ipt) || encounteredError
|
encounteredError = iptables.CleanupLeftovers(ipt) || encounteredError
|
||||||
encounteredError = ipvs.CleanupLeftovers(s.IpvsInterface, ipt, s.IpsetInterface, s.CleanupIPVS) || encounteredError
|
encounteredError = ipvs.CleanupLeftovers(s.IpvsInterface, ipt, s.IpsetInterface) || encounteredError
|
||||||
}
|
}
|
||||||
if encounteredError {
|
if encounteredError {
|
||||||
return errors.New("encountered an error while tearing down rules")
|
return errors.New("encountered an error while tearing down rules")
|
||||||
|
@ -803,13 +803,9 @@ func cleanupIptablesLeftovers(ipt utiliptables.Interface) (encounteredError bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier.
|
// CleanupLeftovers clean up all ipvs and iptables rules created by ipvs Proxier.
|
||||||
func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface, cleanupIPVS bool) (encounteredError bool) {
|
func CleanupLeftovers(ipvs utilipvs.Interface, ipt utiliptables.Interface, ipset utilipset.Interface) (encounteredError bool) {
|
||||||
if cleanupIPVS {
|
// Clear all ipvs rules
|
||||||
// Return immediately when ipvs interface is nil - Probably initialization failed in somewhere.
|
if ipvs != nil {
|
||||||
if ipvs == nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
encounteredError = false
|
|
||||||
err := ipvs.Flush()
|
err := ipvs.Flush()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Error flushing IPVS rules: %v", err)
|
klog.Errorf("Error flushing IPVS rules: %v", err)
|
||||||
|
@ -266,7 +266,7 @@ func TestCleanupLeftovers(t *testing.T) {
|
|||||||
fp.syncProxyRules()
|
fp.syncProxyRules()
|
||||||
|
|
||||||
// test cleanup left over
|
// test cleanup left over
|
||||||
if CleanupLeftovers(ipvs, ipt, ipset, true) {
|
if CleanupLeftovers(ipvs, ipt, ipset) {
|
||||||
t.Errorf("Cleanup leftovers failed")
|
t.Errorf("Cleanup leftovers failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user