cluster-api: Timeout for clusterctl
User Story
As a user of clusterctl client or cli utility, it would greatly benefit me if I could specify a timeout when getting kubeconfig for the cluster:
# clusterctl get kubeconfig foo --kubeconfig-context bar --timeout 10s
or
kubeconfig, err := c.GetKubeconfig(&client.GetKubeconfigOptions{
ParentKubeconfigPath: f,
ParentKubeconfigContext: parentContext,
ManagedClusterNamespace: ref.Namespace,
ManagedClusterName: ref.Name,
Timeout: "10s" // or time.Second * 10
})
.
Detailed Description
The current timeout is 300 seconds. If the management cluster is not reachable, clusterctl will fail after 10 retries to reach the cluster with a 30-second timeout per each try ( controller-runtime client default behavior). When running this command as an interactive user, this seems ok, because you can interrupt it with CTRL+C. However, when done as part of the CI/CD pipeline or another non-interactive script, we have to wait for 300s to understand that cluster is not reachable.
It would be a great help if we could specify this timeout. I think it is easy to implement by using different context here: https://github.com/kubernetes-sigs/cluster-api/blob/master/cmd/clusterctl/client/cluster/workload_cluster.go#L53
func (p *workloadCluster) GetKubeconfig(workloadClusterName string, namespace string, timeout time.Duration) (string, error) {
...
ctxWithTimeout, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
dataBytes, err := utilkubeconfig.FromSecret(ctxWithTimeout, cs, obj)
...
}
/kind feature /area clusterctl
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (9 by maintainers)
@MadhavJivrajani sure, you can pick it up 😃
Sorry for getting late to this issue, but what about considering an approach similar to https://cluster-api.sigs.k8s.io/clusterctl/configuration.html#cert-manager-timeout-override instead of adding a flag to all the clusterctl CLI commands?
Sure, I can do this.