From a86bd891817a206fe28110aba98c02c3deac3992 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Thu, 30 Aug 2018 20:17:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E7=BD=91=E7=BB=9C=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E9=95=9C=E5=83=8F=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=97=B6=E5=AE=89=E8=A3=85=E7=9A=84=E9=94=99=E8=AF=AF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roles/calico/tasks/main.yml | 15 +++++++++++---- roles/cilium/tasks/main.yml | 13 ++++++++++--- roles/flannel/tasks/main.yml | 13 ++++++++++--- roles/kube-router/tasks/main.yml | 11 +++++++++-- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/roles/calico/tasks/main.yml b/roles/calico/tasks/main.yml index 23a2a86..45c73ed 100644 --- a/roles/calico/tasks/main.yml +++ b/roles/calico/tasks/main.yml @@ -31,21 +31,28 @@ ignore_errors: true run_once: true -- name: 准备 calico DaemonSet yaml文件 +- name: 配置 calico DaemonSet yaml文件 template: src=calico.yaml.j2 dest=/opt/kube/kube-system/calico/calico.yaml -- name: 准备 calico rbac文件 +- name: 配置 calico rbac template: src=calico-rbac.yaml.j2 dest=/opt/kube/kube-system/calico/calico-rbac.yaml +- name: 检查是否已下载离线calico镜像 + command: "ls {{ base_dir }}/down" + register: download_info + delegate_to: "{{ groups.deploy[0] }}" + run_once: true + # 【可选】推送离线docker 镜像,可以忽略执行错误 - name: 尝试推送离线docker 镜像(若执行失败,可忽略) copy: src={{ base_dir }}/down/{{ item }} dest=/opt/kube/images/{{ item }} + when: 'item in download_info.stdout' with_items: - "pause_3.1.tar" - "{{ calico_offline }}" ignore_errors: true -- name: 获取目录下离线镜像信息 +- name: 获取calico离线镜像推送情况 command: "ls /opt/kube/images" register: image_info @@ -84,6 +91,6 @@ shell: "{{ bin_dir }}/kubectl get pod -n kube-system -o wide|grep 'calico-node'|grep ' {{ inventory_hostname }} '|awk '{print $3}'" register: pod_status until: pod_status.stdout == "Running" - retries: 12 + retries: 15 delay: 8 diff --git a/roles/cilium/tasks/main.yml b/roles/cilium/tasks/main.yml index 55e7640..484bec5 100644 --- a/roles/cilium/tasks/main.yml +++ b/roles/cilium/tasks/main.yml @@ -39,20 +39,27 @@ ignore_errors: true run_once: true -- name: 准备 cilium DaemonSet yaml文件 +- name: 配置 cilium DaemonSet yaml文件 template: src=cilium.yaml.j2 dest=/opt/kube/kube-system/cilium/cilium.yaml tags: reconf +- name: 检查是否已下载离线cilium镜像 + command: "ls {{ base_dir }}/down" + register: download_info + delegate_to: "{{ groups.deploy[0] }}" + run_once: true + # 【可选】推送离线docker 镜像,可以忽略执行错误 - name: 尝试推送离线docker 镜像(若执行失败,可忽略) copy: src={{ base_dir }}/down/{{ item }} dest=/opt/kube/images/{{ item }} + when: 'item in download_info.stdout' with_items: - "pause_3.1.tar" - "{{ cilium_offline }}" - "{{ busybox_offline }}" ignore_errors: true -- name: 获取目录下离线镜像信息 +- name: 获取cilium离线镜像推送情况 command: "ls /opt/kube/images" register: image_info @@ -80,6 +87,6 @@ shell: "{{ bin_dir }}/kubectl get pod -n kube-system -o wide|grep 'cilium'|grep ' {{ inventory_hostname }} '|awk '{print $3}'" register: pod_status until: pod_status.stdout == "Running" - retries: 12 + retries: 15 delay: 8 diff --git a/roles/flannel/tasks/main.yml b/roles/flannel/tasks/main.yml index a3412d3..2a0144e 100644 --- a/roles/flannel/tasks/main.yml +++ b/roles/flannel/tasks/main.yml @@ -14,18 +14,25 @@ - loopback - portmap -- name: 准备 flannel DaemonSet yaml文件 +- name: 配置 flannel DaemonSet yaml文件 template: src=kube-flannel.yaml.j2 dest=/opt/kube/kube-system/flannel/kube-flannel.yaml +- name: 检查是否已下载离线flannel镜像 + command: "ls {{ base_dir }}/down" + register: download_info + delegate_to: "{{ groups.deploy[0] }}" + run_once: true + # 【可选】推送离线docker 镜像,可以忽略执行错误 - name: 尝试推送离线docker 镜像(若执行失败,可忽略) copy: src={{ base_dir }}/down/{{ item }} dest=/opt/kube/images/{{ item }} + when: 'item in download_info.stdout' with_items: - "pause_3.1.tar" - "{{ flannel_offline }}" ignore_errors: true -- name: 获取目录下离线镜像信息 +- name: 获取flannel离线镜像推送情况 command: "ls /opt/kube/images" register: image_info @@ -52,6 +59,6 @@ shell: "{{ bin_dir }}/kubectl get pod -n kube-system -o wide|grep 'flannel'|grep ' {{ inventory_hostname }} '|awk '{print $3}'" register: pod_status until: pod_status.stdout == "Running" - retries: 12 + retries: 15 delay: 8 diff --git a/roles/kube-router/tasks/main.yml b/roles/kube-router/tasks/main.yml index 87a51ee..6d1214f 100644 --- a/roles/kube-router/tasks/main.yml +++ b/roles/kube-router/tasks/main.yml @@ -33,16 +33,23 @@ template: src=kuberouter-all.yaml.j2 dest=/opt/kube/kube-system/kube-router/kuberouter.yaml when: 'SERVICE_PROXY == "true"' +- name: 检查是否已下载离线kube-router镜像 + command: "ls {{ base_dir }}/down" + register: download_info + delegate_to: "{{ groups.deploy[0] }}" + run_once: true + # 【可选】推送离线docker 镜像,可以忽略执行错误 - name: 尝试推送离线docker 镜像(若执行失败,可忽略) copy: src={{ base_dir }}/down/{{ item }} dest=/opt/kube/images/{{ item }} + when: 'item in download_info.stdout' with_items: - "pause_3.1.tar" - "{{ kuberouter_offline }}" - "{{ busybox_offline }}" ignore_errors: true -- name: 获取目录下离线镜像信息 +- name: 获取kube-router离线镜像推送情况 command: "ls /opt/kube/images" register: image_info @@ -70,6 +77,6 @@ shell: "{{ bin_dir }}/kubectl get pod -n kube-system -o wide|grep 'kube-router'|grep ' {{ inventory_hostname }} '|awk '{print $3}'" register: pod_status until: pod_status.stdout == "Running" - retries: 12 + retries: 15 delay: 8