From 791064a3d96ed11bb38ad294014405a6e280e0eb Mon Sep 17 00:00:00 2001
From: tu1h <92532497+tu1h@users.noreply.github.com>
Date: Tue, 27 Dec 2022 16:53:28 +0800
Subject: [PATCH] Allow custom timeout for kubeadm init (#9617)

Signed-off-by: tu1h <lihai.tu@daocloud.io>

Signed-off-by: tu1h <lihai.tu@daocloud.io>
---
 roles/kubernetes/control-plane/tasks/kubeadm-setup.yml | 2 +-
 roles/kubespray-defaults/defaults/main.yaml            | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml b/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml
index d9f7304ef..3bfd8e27d 100644
--- a/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml
+++ b/roles/kubernetes/control-plane/tasks/kubeadm-setup.yml
@@ -167,7 +167,7 @@
 
 - name: kubeadm | Initialize first master
   command: >-
-    timeout -k 300s 300s
+    timeout -k {{ kubeadm_init_timeout }} {{ kubeadm_init_timeout }}
     {{ bin_dir }}/kubeadm init
     --config={{ kube_config_dir }}/kubeadm-config.yaml
     --ignore-preflight-errors=all
diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml
index 00b738803..6d91768bd 100644
--- a/roles/kubespray-defaults/defaults/main.yaml
+++ b/roles/kubespray-defaults/defaults/main.yaml
@@ -23,6 +23,9 @@ kube_version_min_required: v1.23.0
 ## Kube Proxy mode One of ['iptables','ipvs']
 kube_proxy_mode: ipvs
 
+## The timeout for init first control-plane
+kubeadm_init_timeout: 300s
+
 ## List of kubeadm init phases that should be skipped during control plane setup
 ## By default 'addon/coredns' is skipped
 ## 'addon/kube-proxy' gets skipped for some network plugins
-- 
GitLab