Skip to content

Commit

Permalink
Add CLUSTER_API_KUBECONFIG_READY_TIMEOUT to clusterctl
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <vincepri@vmware.com>
  • Loading branch information
vincepri committed Jun 14, 2019
1 parent 0b215f4 commit 65c8406
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/clusterctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Additional advanced flags can be found via help.

Also, some environment variables are supported:
`CLUSTER_API_MACHINE_READY_TIMEOUT`: set this value to adjust the timeout value in minutes for a machine to become ready, The default timeout is currently 30 minutes, `export CLUSTER_API_MACHINE_READY_TIMEOUT=45` will extend the timeout value to 45 minutes.
`CLUSTER_API_KUBECONFIG_READY_TIMEOUT`: set this value to adjust the timeout value in minutes to wait for the KubeConfig to be ready. Defaults to 20 minutes.

```shell
./clusterctl create cluster --help
Expand Down
17 changes: 14 additions & 3 deletions cmd/clusterctl/phases/getkubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io/ioutil"
"os"
"strconv"
"time"

"k8s.io/klog"
Expand All @@ -29,8 +30,9 @@ import (
)

const (
retryKubeConfigReady = 10 * time.Second
timeoutKubeconfigReady = 20 * time.Minute
TimeoutMachineReadyEnv = "CLUSTER_API_KUBECONFIG_READY_TIMEOUT"
defaultTimeoutKubeconfigReady = 20 * time.Minute
retryKubeConfigReady = 10 * time.Second
)

// GetKubeconfig returns a kubeconfig for the target cluster
Expand All @@ -49,8 +51,17 @@ func GetKubeconfig(bootstrapClient clusterclient.Client, provider provider.Deplo
}

func waitForKubeconfigReady(bootstrapClient clusterclient.Client, provider provider.Deployer, clusterName, namespace string) (string, error) {
timeout := defaultTimeoutKubeconfigReady
if v := os.Getenv(TimeoutMachineReadyEnv); v != "" {
t, err := strconv.Atoi(v)
if err == nil {
timeout = time.Duration(t) * time.Minute
klog.V(4).Infof("Setting KubeConfg timeout to %v", timeout)
}
}

kubeconfig := ""
err := util.PollImmediate(retryKubeConfigReady, timeoutKubeconfigReady, func() (bool, error) {
err := util.PollImmediate(retryKubeConfigReady, timeout, func() (bool, error) {
cluster, controlPlane, _, err := clusterclient.GetClusterAPIObject(bootstrapClient, clusterName, namespace)
if err != nil {
return false, err
Expand Down

0 comments on commit 65c8406

Please sign in to comment.