diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index 7376217e7b..55bda13eb1 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -474,6 +474,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) { nodeConfig.AgentConfig.PrivateRegistry = envInfo.PrivateRegistry nodeConfig.AgentConfig.DisableCCM = controlConfig.DisableCCM nodeConfig.AgentConfig.DisableNPC = controlConfig.DisableNPC + nodeConfig.AgentConfig.DisableKubeProxy = controlConfig.DisableKubeProxy nodeConfig.AgentConfig.Rootless = envInfo.Rootless nodeConfig.DisableSELinux = envInfo.DisableSELinux diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index acdea88bab..c0e78b5e4c 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -44,6 +44,7 @@ type Server struct { DefaultLocalStoragePath string DisableCCM bool DisableNPC bool + DisableKubeProxy bool ClusterInit bool ClusterReset bool EncryptSecrets bool @@ -210,6 +211,11 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { Usage: "(components) Disable k3s default cloud controller manager", Destination: &ServerConfig.DisableCCM, }, + cli.BoolFlag{ + Name: "disable-kube-proxy", + Usage: "(components) Disable running kube-proxy", + Destination: &ServerConfig.DisableKubeProxy, + }, cli.BoolFlag{ Name: "disable-network-policy", Usage: "(components) Disable k3s default network policy controller", diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index d950ec3bf7..2319e518c4 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -98,6 +98,7 @@ func run(app *cli.Context, cfg *cmds.Server) error { serverConfig.ControlConfig.ExtraCloudControllerArgs = cfg.ExtraCloudControllerArgs serverConfig.ControlConfig.DisableCCM = cfg.DisableCCM serverConfig.ControlConfig.DisableNPC = cfg.DisableNPC + serverConfig.ControlConfig.DisableKubeProxy = cfg.DisableKubeProxy serverConfig.ControlConfig.ClusterInit = cfg.ClusterInit serverConfig.ControlConfig.ClusterReset = cfg.ClusterReset serverConfig.ControlConfig.EncryptSecrets = cfg.EncryptSecrets diff --git a/pkg/daemons/agent/agent.go b/pkg/daemons/agent/agent.go index 1344c5224d..fa25b7d471 100644 --- a/pkg/daemons/agent/agent.go +++ b/pkg/daemons/agent/agent.go @@ -29,12 +29,15 @@ func Agent(config *config.Agent) error { defer logs.FlushLogs() startKubelet(config) - startKubeProxy(config) + + if !config.DisableKubeProxy { + return startKubeProxy(config) + } return nil } -func startKubeProxy(cfg *config.Agent) { +func startKubeProxy(cfg *config.Agent) error { argsMap := map[string]string{ "proxy-mode": "iptables", "healthz-bind-address": "127.0.0.1", @@ -53,6 +56,8 @@ func startKubeProxy(cfg *config.Agent) { logrus.Infof("Running kube-proxy %s", config.ArgString(args)) logrus.Fatalf("kube-proxy exited: %v", command.Execute()) }() + + return nil } func startKubelet(cfg *config.Agent) { diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index 9dd87485cf..3d4abe26b3 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -79,6 +79,7 @@ type Agent struct { PrivateRegistry string DisableCCM bool DisableNPC bool + DisableKubeProxy bool Rootless bool } @@ -112,6 +113,7 @@ type Control struct { DefaultLocalStoragePath string DisableCCM bool DisableNPC bool + DisableKubeProxy bool ClusterInit bool ClusterReset bool EncryptSecrets bool