mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Set ClusterDNS to ServiceCIDR network address + 10 when cluster-dns is not provided
This commit is contained in:
parent
7ad03ad8b0
commit
44cce9a76f
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user