Unverified Commit 44634088 authored by Darren Shepherd's avatar Darren Shepherd Committed by GitHub

Merge pull request #239 from takmatsu/add-hosts

Add tls-san flag
parents 9a57e6fd 3a6b3054
...@@ -16,6 +16,7 @@ type Server struct { ...@@ -16,6 +16,7 @@ type Server struct {
DisableAgent bool DisableAgent bool
KubeConfigOutput string KubeConfigOutput string
KubeConfigMode string KubeConfigMode string
KnownIPs cli.StringSlice
} }
var ServerConfig Server var ServerConfig Server
...@@ -94,6 +95,11 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { ...@@ -94,6 +95,11 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
Destination: &ServerConfig.KubeConfigMode, Destination: &ServerConfig.KubeConfigMode,
EnvVar: "K3S_KUBECONFIG_MODE", 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, NodeIPFlag,
NodeNameFlag, NodeNameFlag,
DockerFlag, DockerFlag,
......
...@@ -77,7 +77,7 @@ func run(app *cli.Context, cfg *cmds.Server) error { ...@@ -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.KnownIPs)
_, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR) _, serverConfig.ControlConfig.ClusterIPRange, err = net2.ParseCIDR(cfg.ClusterCIDR)
if err != nil { if err != nil {
...@@ -146,10 +146,8 @@ func run(app *cli.Context, cfg *cmds.Server) error { ...@@ -146,10 +146,8 @@ func run(app *cli.Context, cfg *cmds.Server) error {
return agent.Run(ctx, agentConfig) return agent.Run(ctx, agentConfig)
} }
func knownIPs() []string { func knownIPs(ips []string) []string {
ips := []string{ ips = append(ips, "127.0.0.1")
"127.0.0.1",
}
ip, err := net.ChooseHostInterface() ip, err := net.ChooseHostInterface()
if err == nil { if err == nil {
ips = append(ips, ip.String()) ips = append(ips, ip.String())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment