Skip to content

Commit 65c8406

Browse files
committed
Add CLUSTER_API_KUBECONFIG_READY_TIMEOUT to clusterctl
Signed-off-by: Vince Prignano <[email protected]>
1 parent 0b215f4 commit 65c8406

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

cmd/clusterctl/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Additional advanced flags can be found via help.
6363

6464
Also, some environment variables are supported:
6565
`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.
66+
`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.
6667

6768
```shell
6869
./clusterctl create cluster --help

cmd/clusterctl/phases/getkubeconfig.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"io/ioutil"
2222
"os"
23+
"strconv"
2324
"time"
2425

2526
"k8s.io/klog"
@@ -29,8 +30,9 @@ import (
2930
)
3031

3132
const (
32-
retryKubeConfigReady = 10 * time.Second
33-
timeoutKubeconfigReady = 20 * time.Minute
33+
TimeoutMachineReadyEnv = "CLUSTER_API_KUBECONFIG_READY_TIMEOUT"
34+
defaultTimeoutKubeconfigReady = 20 * time.Minute
35+
retryKubeConfigReady = 10 * time.Second
3436
)
3537

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

5153
func waitForKubeconfigReady(bootstrapClient clusterclient.Client, provider provider.Deployer, clusterName, namespace string) (string, error) {
54+
timeout := defaultTimeoutKubeconfigReady
55+
if v := os.Getenv(TimeoutMachineReadyEnv); v != "" {
56+
t, err := strconv.Atoi(v)
57+
if err == nil {
58+
timeout = time.Duration(t) * time.Minute
59+
klog.V(4).Infof("Setting KubeConfg timeout to %v", timeout)
60+
}
61+
}
62+
5263
kubeconfig := ""
53-
err := util.PollImmediate(retryKubeConfigReady, timeoutKubeconfigReady, func() (bool, error) {
64+
err := util.PollImmediate(retryKubeConfigReady, timeout, func() (bool, error) {
5465
cluster, controlPlane, _, err := clusterclient.GetClusterAPIObject(bootstrapClient, clusterName, namespace)
5566
if err != nil {
5667
return false, err

0 commit comments

Comments
 (0)