From 44cce9a76fadae2e79f24e5246f270ad3e4c97bd Mon Sep 17 00:00:00 2001 From: Vladimir Zorin Date: Wed, 6 Mar 2019 20:41:07 +0200 Subject: [PATCH] Set ClusterDNS to ServiceCIDR network address + 10 when cluster-dns is not provided --- pkg/cli/cmds/server.go | 2 +- pkg/cli/server/server.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index 5691d7a0b7..7e68f0b854 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -76,7 +76,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { Name: "cluster-dns", Usage: "Cluster IP for coredns service. Should be in your service-cidr range", Destination: &ServerConfig.ClusterDNS, - Value: "10.43.0.10", + Value: "", }, cli.StringSliceFlag{ Name: "no-deploy", diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index 2420ccb9cc..3bdefd7843 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -86,7 +86,17 @@ func run(app *cli.Context, cfg *cmds.Server) error { if err != nil { return errors.Wrapf(err, "Invalid CIDR %s: %v", cfg.ServiceCIDR, err) } - serverConfig.ControlConfig.ClusterDNS = net2.ParseIP(cfg.ClusterDNS) + + // If cluster-dns CLI arg is not set, we set ClusterDNS address to be ServiceCIDR network + 10, + // i.e. when you set service-cidr to 192.168.0.0/16 and don't provide cluster-dns, it will be set to 192.168.0.10 + if cfg.ClusterDNS == "" { + serverConfig.ControlConfig.ClusterDNS = make(net2.IP, 4) + copy(serverConfig.ControlConfig.ClusterDNS, serverConfig.ControlConfig.ServiceIPRange.IP.To4()) + serverConfig.ControlConfig.ClusterDNS[3] = 10 + } else { + serverConfig.ControlConfig.ClusterDNS = net2.ParseIP(cfg.ClusterDNS) + } + // TODO: support etcd serverConfig.ControlConfig.NoLeaderElect = true