diff --git a/cmd/cert.go b/cmd/cert.go index 082fae09..821ddc86 100644 --- a/cmd/cert.go +++ b/cmd/cert.go @@ -152,7 +152,9 @@ func rebuildClusterWithRotatedCertificates(ctx context.Context, if err := cluster.SetUpAuthentication(ctx, kubeCluster, nil, clusterState); err != nil { return APIURL, caCrt, clientCert, clientKey, nil, err } - APIURL = fmt.Sprintf("https://%s:6443", kubeCluster.ControlPlaneHosts[0].Address) + if len(kubeCluster.ControlPlaneHosts) > 0 { + APIURL = fmt.Sprintf("https://%s:6443", kubeCluster.ControlPlaneHosts[0].Address) + } clientCert = string(cert.EncodeCertPEM(kubeCluster.Certificates[pki.KubeAdminCertName].Certificate)) clientKey = string(cert.EncodePrivateKeyPEM(kubeCluster.Certificates[pki.KubeAdminCertName].Key)) caCrt = string(cert.EncodeCertPEM(kubeCluster.Certificates[pki.CACertName].Certificate))