fix(build): kubectl download add --max-time 120 + aliyun mirror fallback
This commit is contained in:
1 parent
17059bff98
commit
d40042d86e
1 file changed
+6
-2
@@ -27,12 +27,16 @@ esac
|
||||
|
||||
PRIMARY="https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/${TARGET_OS}/${KARCH}/kubectl"
|
||||
FALLBACK="https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/${TARGET_OS}/${KARCH}/kubectl"
|
||||
MIRROR_CN="https://mirrors.aliyun.com/kubernetes/release/${KUBECTL_VERSION}/bin/${TARGET_OS}/${KARCH}/kubectl"
|
||||
|
||||
echo "[install-kubectl] ${TARGET_OS}/${KARCH} ${KUBECTL_VERSION} -> ${DEST}"
|
||||
|
||||
if curl -fsSL --retry 3 --retry-delay 2 --connect-timeout 20 "${PRIMARY}" -o "${DEST}"; then
|
||||
# --max-time 120 限制单次下载总时长,--connect-timeout 20 限制连接阶段 // Logan.Li
|
||||
if curl -fsSL --retry 3 --retry-delay 2 --connect-timeout 20 --max-time 120 "${PRIMARY}" -o "${DEST}"; then
|
||||
:
|
||||
elif curl -fsSL --retry 3 --retry-delay 2 --connect-timeout 20 "${FALLBACK}" -o "${DEST}"; then
|
||||
elif curl -fsSL --retry 3 --retry-delay 2 --connect-timeout 20 --max-time 120 "${MIRROR_CN}" -o "${DEST}"; then
|
||||
echo "[install-kubectl] 使用阿里云镜像: ${MIRROR_CN}"
|
||||
elif curl -fsSL --retry 3 --retry-delay 2 --connect-timeout 20 --max-time 120 "${FALLBACK}" -o "${DEST}"; then
|
||||
echo "[install-kubectl] 使用备用源: ${FALLBACK}"
|
||||
else
|
||||
echo "[install-kubectl] 下载失败: ${PRIMARY}" >&2
|
||||
|
||||
Reference in new issue
Block a user