@@ -393,23 +393,7 @@ func (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, wellKnownAddre
393393
394394 useConfigServer := kopsmodel .UseKopsControllerForNodeConfig (cluster ) && ! ig .HasAPIServer ()
395395 if useConfigServer {
396- hosts := []string {"kops-controller.internal." + cluster .ObjectMeta .Name }
397- if len (bootConfig .APIServerIPs ) > 0 {
398- hosts = bootConfig .APIServerIPs
399- }
400-
401- configServer := & nodeup.ConfigServerOptions {
402- CACertificates : config .CAs [fi .CertificateIDCA ],
403- }
404- for _ , host := range hosts {
405- baseURL := url.URL {
406- Scheme : "https" ,
407- Host : net .JoinHostPort (host , strconv .Itoa (wellknownports .KopsControllerPort )),
408- Path : "/" ,
409- }
410- configServer .Servers = append (configServer .Servers , baseURL .String ())
411- }
412- bootConfig .ConfigServer = configServer
396+ bootConfig .ConfigServer = buildConfigServerOptions (cluster .ObjectMeta .Name , config .CAs [fi .CertificateIDCA ], bootConfig .APIServerIPs )
413397 delete (config .CAs , fi .CertificateIDCA )
414398 } else {
415399 bootConfig .ConfigBase = fi .PtrTo (n .configBase .Path ())
@@ -465,6 +449,30 @@ func (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, wellKnownAddre
465449 return config , bootConfig , nil
466450}
467451
452+ func buildConfigServerOptions (clusterName string , caCertificates string , apiserverIPs []string ) * nodeup.ConfigServerOptions {
453+ kopsControllerName := "kops-controller.internal." + clusterName
454+ hosts := []string {kopsControllerName }
455+
456+ configServer := & nodeup.ConfigServerOptions {
457+ CACertificates : caCertificates ,
458+ }
459+ if len (apiserverIPs ) > 0 {
460+ hosts = apiserverIPs
461+ configServer .TLSServerName = kopsControllerName
462+ }
463+
464+ for _ , host := range hosts {
465+ baseURL := url.URL {
466+ Scheme : "https" ,
467+ Host : net .JoinHostPort (host , strconv .Itoa (wellknownports .KopsControllerPort )),
468+ Path : "/" ,
469+ }
470+ configServer .Servers = append (configServer .Servers , baseURL .String ())
471+ }
472+
473+ return configServer
474+ }
475+
468476func loadCertificates (keysets map [string ]* fi.Keyset , name string , config * nodeup.Config , includeKeypairID bool ) error {
469477 keyset := keysets [name ]
470478 if keyset == nil {
0 commit comments