Skip to content

Commit ebe2fa6

Browse files
authored
tests: split kubectl download task into multiple with retries (kubernetes#3059)
1 parent ce4af77 commit ebe2fa6

File tree

1 file changed

+26
-3
lines changed
  • tests/playbooks/roles/install-k3s/tasks

1 file changed

+26
-3
lines changed

tests/playbooks/roles/install-k3s/tasks/main.yaml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,39 @@
154154
retries: 100
155155
delay: 5
156156

157-
- name: Prepare kubectl and kubeconfig file
157+
- name: Prepare kubeconfig file
158158
shell:
159159
executable: /bin/bash
160160
cmd: |
161161
set -ex
162162
163163
mkdir -p {{ ansible_user_dir }}/.kube
164164
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ ansible_user_dir }}/.ssh/id_rsa ubuntu@{{ k3s_fip }}:/etc/rancher/k3s/k3s.yaml {{ ansible_user_dir }}/.kube/config
165-
curl -sLO# https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
166-
chmod +x ./kubectl; sudo mv ./kubectl /usr/local/bin/kubectl
165+
166+
- name: Get latest kubectl version
167+
uri:
168+
url: https://dl.k8s.io/release/stable.txt
169+
return_content: yes
170+
register: kubectl_version
171+
retries: 5
172+
delay: 10
173+
until: kubectl_version.status == 200
174+
175+
- name: Download kubectl binary
176+
get_url:
177+
url: "https://dl.k8s.io/release/{{ kubectl_version.content | trim }}/bin/linux/amd64/kubectl"
178+
dest: /usr/local/bin/kubectl
179+
mode: '0755'
180+
become: true
181+
retries: 5
182+
delay: 10
183+
184+
- name: Set kubectl cluster config
185+
shell:
186+
executable: /bin/bash
187+
cmd: |
188+
set -ex
189+
167190
kubectl config set-cluster default --server=https://{{ k3s_fip }}:6443 --kubeconfig {{ ansible_user_dir }}/.kube/config
168191
169192
- name: Wait for k8s node ready

0 commit comments

Comments
 (0)