Merge pull request #239 from takmatsu/add-hosts

Add tls-san flag
This commit is contained in:
Darren Shepherd 2019-03-25 09:54:21 -07:00 committed by GitHub
commit 4463408819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -16,6 +16,7 @@ type Server struct {
DisableAgent bool
KubeConfigOutput string
KubeConfigMode string
KnownIPs cli.StringSlice
}
var ServerConfig Server
@ -94,6 +95,11 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
Destination: &ServerConfig.KubeConfigMode,
EnvVar: "K3S_KUBECONFIG_MODE",
},
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,
DockerFlag,

View File

@ -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()
serverConfig.TLSConfig.KnownIPs = knownIPs(cfg.KnownIPs)
_, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR)
if err != nil {
@ -146,10 +146,8 @@ func run(app *cli.Context, cfg *cmds.Server) error {
return agent.Run(ctx, agentConfig)
}
func knownIPs() []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())