@@ -78,6 +78,14 @@ func (e *Engine) SetSpec(config *Config) error {
78
78
79
79
e .Spec = config
80
80
81
+ // If TLS SANs are configured, the first one will be used as the server URL.
82
+ // If not, the host address of the first controlplane will be used.
83
+ firstControlplane := e .FilterNodes (RoleServer )[0 ]
84
+ e .serverURL = fmt .Sprintf ("https://%s:6443" , firstControlplane .SSH .Host )
85
+ if len (e .Spec .Cluster .TLSSAN ) > 0 {
86
+ e .serverURL = fmt .Sprintf ("https://%s:6443" , e .Spec .Cluster .TLSSAN [0 ])
87
+ }
88
+
81
89
return nil
82
90
}
83
91
@@ -148,9 +156,7 @@ func (e *Engine) ConfigureNode(node *Node) error {
148
156
149
157
// Install runs the installation script on the node.
150
158
func (e * Engine ) Install () error {
151
- if err := e .configureServerURL (); err != nil {
152
- return err
153
- }
159
+ e .Logger .Info ().Str ("server_url" , e .serverURL ).Msg ("Detecting server URL" )
154
160
155
161
if err := e .installControlPlanes (); err != nil {
156
162
return err
@@ -326,20 +332,6 @@ func (e *Engine) KubeConfig(outputPath string) error {
326
332
return clientcmd .WriteToFile (* oldConfig , outputPath )
327
333
}
328
334
329
- // configureServerURL assembles the server URL based on the given spec.
330
- func (e * Engine ) configureServerURL () error {
331
- // If TLS SANs are configured, the first one will be used as the server URL.
332
- // If not, the host address of the first controlplane will be used.
333
- firstControlplane := e .FilterNodes (RoleServer )[0 ]
334
- e .serverURL = fmt .Sprintf ("https://%s:6443" , firstControlplane .SSH .Host )
335
- if len (e .Spec .Cluster .TLSSAN ) > 0 {
336
- e .serverURL = fmt .Sprintf ("https://%s:6443" , e .Spec .Cluster .TLSSAN [0 ])
337
- }
338
- e .Logger .Info ().Str ("server_url" , e .serverURL ).Msg ("Configuring server URL" )
339
-
340
- return nil
341
- }
342
-
343
335
// fetchInstallationScript returns the downloaded the k3s installer.
344
336
func (e * Engine ) fetchInstallationScript () ([]byte , error ) {
345
337
// Lock engine to prevent concurrent access to installer cache.
0 commit comments