diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index 951053f8a0..305b1e8ae5 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -65,6 +65,12 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { Destination: &ServerConfig.ClusterSecret, EnvVar: "K3S_CLUSTER_SECRET", }, + cli.StringFlag{ + Name: "service-cidr", + Usage: "Network CIDR to use for services IPs", + Destination: &ServerConfig.ServiceCIDR, + Value: "10.43.0.0/16", + }, cli.StringSliceFlag{ Name: "no-deploy", Usage: "Do not deploy packaged components (valid items: coredns, servicelb, traefik)", diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index 721f124c76..0399b6c72a 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -82,6 +82,10 @@ func run(app *cli.Context, cfg *cmds.Server) error { if err != nil { return errors.Wrapf(err, "Invalid CIDR %s: %v", cfg.ClusterCIDR, err) } + _, serverConfig.ControlConfig.ServiceIPRange, err = net2.ParseCIDR(cfg.ServiceCIDR) + if err != nil { + return errors.Wrapf(err, "Invalid CIDR %s: %v", cfg.ServiceCIDR, err) + } // TODO: support etcd serverConfig.ControlConfig.NoLeaderElect = true