fix: use mounted kubectl, fallback to official dl.k8s.io
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
zyc 2026-04-13 19:23:46 +08:00
parent b8ecaf44d0
commit c6d5a1c935

View File

@ -71,12 +71,15 @@ jobs:
- name: Setup Kubectl - name: Setup Kubectl
run: | run: |
if ! command -v kubectl &>/dev/null; then if ! command -v kubectl &>/dev/null; then
for attempt in 1 2 3; do echo "kubectl not found, using mounted binary or downloading..."
curl -LO "https://files.m.daocloud.io/dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl" && break if [ -f /usr/local/bin/kubectl ]; then
echo "Download attempt $attempt failed, retrying in 5s..." && sleep 5 echo "kubectl found at /usr/local/bin/kubectl"
done else
curl -LO "https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl" || \
curl -LO "https://files.m.daocloud.io/dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl"
chmod +x kubectl && mv kubectl /usr/bin/kubectl chmod +x kubectl && mv kubectl /usr/bin/kubectl
fi fi
fi
kubectl version --client kubectl version --client
- name: Set kubeconfig - name: Set kubeconfig