diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index cafc4bb3d3..6000c5960c 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -57,6 +57,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { Name: "cluster-cidr", Usage: "Network CIDR to use for pod IPs", Destination: &ServerConfig.ClusterCIDR, + Value: "10.42.0.0/16", }, cli.StringFlag{ Name: "cluster-secret", diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index d4c5a9c37d..e9659bd74e 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -4,6 +4,7 @@ import ( "context" "flag" "fmt" + net2 "net" "os" "path/filepath" "strings" @@ -11,6 +12,7 @@ import ( systemd "github.com/coreos/go-systemd/daemon" "github.com/docker/docker/pkg/reexec" "github.com/natefinch/lumberjack" + "github.com/pkg/errors" "github.com/rancher/k3s/pkg/agent" "github.com/rancher/k3s/pkg/cli/cmds" "github.com/rancher/k3s/pkg/server" @@ -56,6 +58,10 @@ func Run(app *cli.Context) error { } func run(app *cli.Context, cfg *cmds.Server) error { + var ( + err error + ) + if cfg.Log != "" && os.Getenv("_RIO_REEXEC_") == "" { return runWithLogging(app, cfg) } @@ -75,6 +81,11 @@ func run(app *cli.Context, cfg *cmds.Server) error { serverConfig.TLSConfig.HTTPPort = cfg.HTTPPort serverConfig.TLSConfig.KnownIPs = knownIPs() + _, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR) + if err != nil { + return errors.Wrapf(err, "Invalid CIDR %s: %v", cfg.ClusterCIDR, err) + } + // TODO: support etcd serverConfig.ControlConfig.NoLeaderElect = true