From 4adb695b47aed953fdf85c8aabd2f599414b552c Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Fri, 25 Oct 2019 11:16:48 +0200 Subject: [PATCH] add tls san for non-default host name --- pkg/cluster/node.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/cluster/node.go b/pkg/cluster/node.go index a5ace7d9..3acfd7c9 100644 --- a/pkg/cluster/node.go +++ b/pkg/cluster/node.go @@ -119,19 +119,17 @@ func patchMasterSpec(node *k3d.Node) error { apiPort := "6443" // TODO: from defaults if node.MasterOpts.ExposeAPI.Port != "" { - apiPort = node.MasterOpts.ExposeAPI.Port node.Labels["k3d.master.api.port"] = node.MasterOpts.ExposeAPI.Port + } - if node.MasterOpts.ExposeAPI.Host != "" { + if node.MasterOpts.ExposeAPI.Host != "" { + hostIP = node.MasterOpts.ExposeAPI.HostIP + node.Labels["k3d.master.api.hostIP"] = node.MasterOpts.ExposeAPI.HostIP // TODO: maybe get docker machine IP here - hostIP = node.MasterOpts.ExposeAPI.HostIP - node.Labels["k3d.master.api.hostIP"] = node.MasterOpts.ExposeAPI.HostIP // TODO: maybe get docker machine IP here - - node.Labels["k3d.master.api.host"] = node.MasterOpts.ExposeAPI.Host - - } + node.Labels["k3d.master.api.host"] = node.MasterOpts.ExposeAPI.Host + node.Args = append(node.Args, "--tls-san", node.MasterOpts.ExposeAPI.Host) // add TLS SAN for non default host name } node.Ports = append(node.Ports, fmt.Sprintf("%s:%s:6443/tcp", hostIP, apiPort)) // TODO: get '6443' from defaultport variable