Skip to content

Add CLUSTER_API_KUBECONFIG_READY_TIMEOUT to clusterctl #1026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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