Skip to content

Commit

Permalink
Merge pull request #83 from kahun/fix/eks_get_kubeconfig
Browse files Browse the repository at this point in the history
Add retries retrieving kubeconfig
  • Loading branch information
stg-0 authored Mar 30, 2023
2 parents f0fdd2e + 653cbaa commit 66a6114
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/cluster/internal/create/actions/createworker/createworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,26 @@ func (a *action) Execute(ctx *actions.ActionContext) error {
return errors.Wrap(err, "failed to create the worker Cluster")
}

// Get the workload cluster kubeconfig
// Wait for the control plane initialization
raw = bytes.Buffer{}
cmd = node.Command("sh", "-c", "clusterctl -n "+capiClustersNamespace+" get kubeconfig "+descriptorFile.ClusterID+" | tee "+kubeconfigPath)
cmd = node.Command("kubectl", "-n", capiClustersNamespace, "wait", "--for=condition=ControlPlaneInitialized", "--timeout", "5m", "cluster", descriptorFile.ClusterID)
if err := cmd.SetStdout(&raw).Run(); err != nil {
return errors.Wrap(err, "failed to get workload cluster kubeconfig")
return errors.Wrap(err, "failed to create the worker Cluster")
}
kubeconfig := raw.String()

ctx.Status.End(true) // End Creating the workload cluster

ctx.Status.Start("Saving the workload cluster kubeconfig 📝")
defer ctx.Status.End(false)

// Get the workload cluster kubeconfig
raw = bytes.Buffer{}
cmd = node.Command("sh", "-c", "clusterctl -n "+capiClustersNamespace+" get kubeconfig "+descriptorFile.ClusterID+" | tee "+kubeconfigPath)
if err := cmd.SetStdout(&raw).SetStderr(&raw).Run(); err != nil || strings.Contains(raw.String(), "Error:") || raw.String() == "" {
return errors.Wrap(err, "failed to get workload cluster kubeconfig")
}
kubeconfig := raw.String()

workKubeconfigBasePath := strings.Split(workKubeconfigPath, "/")[0]
_, err = os.Stat(workKubeconfigBasePath)
if err != nil {
Expand Down

0 comments on commit 66a6114

Please sign in to comment.