mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Add advertise-address flag
In NAT or LB environment, we need not just the certs for local ip, but also additional ips. advertise-address flag enables to add optional ips.
This commit is contained in:
parent
697c6e1580
commit
9551e1db21
@ -16,6 +16,7 @@ type Server struct {
|
|||||||
DisableAgent bool
|
DisableAgent bool
|
||||||
KubeConfigOutput string
|
KubeConfigOutput string
|
||||||
KubeConfigMode string
|
KubeConfigMode string
|
||||||
|
AdvertiseAddress string
|
||||||
}
|
}
|
||||||
|
|
||||||
var ServerConfig Server
|
var ServerConfig Server
|
||||||
@ -94,6 +95,12 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
|||||||
Destination: &ServerConfig.KubeConfigMode,
|
Destination: &ServerConfig.KubeConfigMode,
|
||||||
EnvVar: "K3S_KUBECONFIG_MODE",
|
EnvVar: "K3S_KUBECONFIG_MODE",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "advertise-address",
|
||||||
|
Usage: "Advertise address for k3s server",
|
||||||
|
Destination: &ServerConfig.AdvertiseAddress,
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
NodeIPFlag,
|
NodeIPFlag,
|
||||||
NodeNameFlag,
|
NodeNameFlag,
|
||||||
DockerFlag,
|
DockerFlag,
|
||||||
|
@ -77,7 +77,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
|||||||
serverConfig.ControlConfig.KubeConfigMode = cfg.KubeConfigMode
|
serverConfig.ControlConfig.KubeConfigMode = cfg.KubeConfigMode
|
||||||
serverConfig.TLSConfig.HTTPSPort = cfg.HTTPSPort
|
serverConfig.TLSConfig.HTTPSPort = cfg.HTTPSPort
|
||||||
serverConfig.TLSConfig.HTTPPort = cfg.HTTPPort
|
serverConfig.TLSConfig.HTTPPort = cfg.HTTPPort
|
||||||
serverConfig.TLSConfig.KnownIPs = knownIPs()
|
serverConfig.TLSConfig.KnownIPs = knownIPs(cfg.AdvertiseAddress)
|
||||||
|
|
||||||
_, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR)
|
_, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -146,7 +146,7 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
|||||||
return agent.Run(ctx, agentConfig)
|
return agent.Run(ctx, agentConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func knownIPs() []string {
|
func knownIPs(hosts string) []string {
|
||||||
ips := []string{
|
ips := []string{
|
||||||
"127.0.0.1",
|
"127.0.0.1",
|
||||||
}
|
}
|
||||||
@ -154,5 +154,10 @@ func knownIPs() []string {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
ips = append(ips, ip.String())
|
ips = append(ips, ip.String())
|
||||||
}
|
}
|
||||||
|
for _, host := range strings.Split(hosts, ",") {
|
||||||
|
if host != "" {
|
||||||
|
ips = append(ips, host)
|
||||||
|
}
|
||||||
|
}
|
||||||
return ips
|
return ips
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user