mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Change flag name and type
This commit is contained in:
parent
9551e1db21
commit
3a6b305455
@ -16,7 +16,7 @@ type Server struct {
|
||||
DisableAgent bool
|
||||
KubeConfigOutput string
|
||||
KubeConfigMode string
|
||||
AdvertiseAddress string
|
||||
KnownIPs cli.StringSlice
|
||||
}
|
||||
|
||||
var ServerConfig Server
|
||||
@ -95,11 +95,10 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
||||
Destination: &ServerConfig.KubeConfigMode,
|
||||
EnvVar: "K3S_KUBECONFIG_MODE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "advertise-address",
|
||||
Usage: "Advertise address for k3s server",
|
||||
Destination: &ServerConfig.AdvertiseAddress,
|
||||
Value: "",
|
||||
cli.StringSliceFlag{
|
||||
Name: "tls-san",
|
||||
Usage: "Add additional hostname or IP as a Subject Alternative Name in the TLS cert",
|
||||
Value: &ServerConfig.KnownIPs,
|
||||
},
|
||||
NodeIPFlag,
|
||||
NodeNameFlag,
|
||||
|
@ -77,7 +77,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
||||
serverConfig.ControlConfig.KubeConfigMode = cfg.KubeConfigMode
|
||||
serverConfig.TLSConfig.HTTPSPort = cfg.HTTPSPort
|
||||
serverConfig.TLSConfig.HTTPPort = cfg.HTTPPort
|
||||
serverConfig.TLSConfig.KnownIPs = knownIPs(cfg.AdvertiseAddress)
|
||||
serverConfig.TLSConfig.KnownIPs = knownIPs(cfg.KnownIPs)
|
||||
|
||||
_, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR)
|
||||
if err != nil {
|
||||
@ -146,18 +146,11 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
||||
return agent.Run(ctx, agentConfig)
|
||||
}
|
||||
|
||||
func knownIPs(hosts string) []string {
|
||||
ips := []string{
|
||||
"127.0.0.1",
|
||||
}
|
||||
func knownIPs(ips []string) []string {
|
||||
ips = append(ips, "127.0.0.1")
|
||||
ip, err := net.ChooseHostInterface()
|
||||
if err == nil {
|
||||
ips = append(ips, ip.String())
|
||||
}
|
||||
for _, host := range strings.Split(hosts, ",") {
|
||||
if host != "" {
|
||||
ips = append(ips, host)
|
||||
}
|
||||
}
|
||||
return ips
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user