Commit 400225e7 authored by Darren Shepherd's avatar Darren Shepherd

Prepopulate known IPs in TLS

parent 529e22ef
...@@ -8,6 +8,8 @@ import ( ...@@ -8,6 +8,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"k8s.io/apimachinery/pkg/util/net"
"github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/reexec"
"github.com/natefinch/lumberjack" "github.com/natefinch/lumberjack"
"github.com/rancher/k3s/pkg/agent" "github.com/rancher/k3s/pkg/agent"
...@@ -69,6 +71,7 @@ func run(app *cli.Context, cfg *cmds.Server) error { ...@@ -69,6 +71,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()
// TODO: support etcd // TODO: support etcd
serverConfig.ControlConfig.NoLeaderElect = true serverConfig.ControlConfig.NoLeaderElect = true
...@@ -104,3 +107,14 @@ func run(app *cli.Context, cfg *cmds.Server) error { ...@@ -104,3 +107,14 @@ func run(app *cli.Context, cfg *cmds.Server) error {
return agent.Run(ctx, agentConfig) return agent.Run(ctx, agentConfig)
} }
func knownIPs() []string {
ips := []string{
"127.0.0.1",
}
ip, err := net.ChooseHostInterface()
if err == nil {
ips = append(ips, ip.String())
}
return ips
}
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