mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
add cleanup-ipvs flag
This commit is contained in:
@@ -95,7 +95,8 @@ type Options struct {
|
||||
WriteConfigTo string
|
||||
// CleanupAndExit, when true, makes the proxy server clean up iptables rules, then exit.
|
||||
CleanupAndExit bool
|
||||
|
||||
// CleanupIPVS, when true, makes the proxy server clean up ipvs rules before running.
|
||||
CleanupIPVS bool
|
||||
// config is the proxy server's configuration object.
|
||||
config *kubeproxyconfig.KubeProxyConfiguration
|
||||
|
||||
@@ -120,6 +121,7 @@ func AddFlags(options *Options, fs *pflag.FlagSet) {
|
||||
fs.BoolVar(&options.CleanupAndExit, "cleanup-iptables", options.CleanupAndExit, "If true cleanup iptables and ipvs rules and exit.")
|
||||
fs.MarkDeprecated("cleanup-iptables", "This flag is replaced by --cleanup.")
|
||||
fs.BoolVar(&options.CleanupAndExit, "cleanup", options.CleanupAndExit, "If true cleanup iptables and ipvs rules and exit.")
|
||||
fs.BoolVar(&options.CleanupIPVS, "cleanup-ipvs", options.CleanupIPVS, "If true make kube-proxy cleanup ipvs rules before running. Default is true")
|
||||
|
||||
// All flags below here are deprecated and will eventually be removed.
|
||||
|
||||
@@ -173,6 +175,7 @@ func NewOptions() *Options {
|
||||
healthzPort: ports.ProxyHealthzPort,
|
||||
scheme: scheme.Scheme,
|
||||
codecs: scheme.Codecs,
|
||||
CleanupIPVS: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +218,7 @@ func (o *Options) Run() error {
|
||||
return o.writeConfigFile()
|
||||
}
|
||||
|
||||
proxyServer, err := NewProxyServer(o.config, o.CleanupAndExit, o.scheme, o.master)
|
||||
proxyServer, err := NewProxyServer(o.config, o.CleanupAndExit, o.CleanupIPVS, o.scheme, o.master)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -367,6 +370,7 @@ type ProxyServer struct {
|
||||
ProxyMode string
|
||||
NodeRef *v1.ObjectReference
|
||||
CleanupAndExit bool
|
||||
CleanupIPVS bool
|
||||
MetricsBindAddress string
|
||||
EnableProfiling bool
|
||||
OOMScoreAdj *int32
|
||||
@@ -424,7 +428,7 @@ func (s *ProxyServer) Run() error {
|
||||
if s.CleanupAndExit {
|
||||
encounteredError := userspace.CleanupLeftovers(s.IptInterface)
|
||||
encounteredError = iptables.CleanupLeftovers(s.IptInterface) || encounteredError
|
||||
encounteredError = ipvs.CleanupLeftovers(s.IpvsInterface, s.IptInterface, s.IpsetInterface) || encounteredError
|
||||
encounteredError = ipvs.CleanupLeftovers(s.IpvsInterface, s.IptInterface, s.IpsetInterface, s.CleanupIPVS) || encounteredError
|
||||
if encounteredError {
|
||||
return errors.New("encountered an error while tearing down rules.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user