Set cluster config as early as possible
@@ -90,12 +90,21 @@ func ClusterUp(
if err != nil {
return APIURL, caCrt, clientCert, clientKey, nil, err
}
+ if len(kubeCluster.ControlPlaneHosts) > 0 {
+ APIURL = fmt.Sprintf("https://" + kubeCluster.ControlPlaneHosts[0].Address + ":6443")
+ }
+ 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))
err = cluster.ReconcileCluster(ctx, kubeCluster, currentCluster, updateOnly)
if err != nil {
return APIURL, caCrt, clientCert, clientKey, nil, err
}
-
+ // update APIURL after reconcile
+ if len(kubeCluster.ControlPlaneHosts) > 0 {
+ APIURL = fmt.Sprintf("https://" + kubeCluster.ControlPlaneHosts[0].Address + ":6443")
+ }
err = kubeCluster.SetUpHosts(ctx)
if err != nil {
return APIURL, caCrt, clientCert, clientKey, nil, err
@@ -139,12 +148,6 @@ func ClusterUp(
if err != nil {
return APIURL, caCrt, clientCert, clientKey, nil, err
}
- if len(kubeCluster.ControlPlaneHosts) > 0 {
- APIURL = fmt.Sprintf("https://" + kubeCluster.ControlPlaneHosts[0].Address + ":6443")
- 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))
if err := checkAllIncluded(kubeCluster); err != nil {
return APIURL, caCrt, clientCert, clientKey, nil, err
