Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安装新node后推送所有镜像,防止某些镜像不存在 #650

Merged
merged 2 commits into from
Jul 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tools/02.addnode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@
- { role: flannel, when: "CLUSTER_NETWORK == 'flannel'" }
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
- { role: kube-ovn, when: "CLUSTER_NETWORK == 'kube-ovn'" }
post_tasks:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post_tasks 建议改成 tasks
post_tasks: 不管前面部分成功或者失败,都会被执行,这应该不是我们想要的

- name: 推送所有离线镜像包
copy: src={{ base_dir }}/down/ dest=/opt/kube/images/
Copy link
Collaborator

@gjmzj gjmzj Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里把 down目录下都复制过去,东西太多了,里面还有离线系统包 packages,会导致执行时间长;
建议只复制需要的tar包即可:coredns*.tar dashboard*.tar heapster*.tar metrics*.tar traefik*.tar,参考如下

  - name: create images directory
    file: dest=/opt/kube/images state=directory
  - name: copy offline images
    copy: src={{ item }} dest=/opt/kube/images/
    with_fileglob:
      - "{{ base_dir }}/down/coredns*.tar"
      - "{{ base_dir }}/down/dashboard*.tar"
      - "{{ base_dir }}/down/heapster*.tar"
      - "{{ base_dir }}/down/metrics*.tar"
      - "{{ base_dir }}/down/traefik*.tar"
    ignore_errors: true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样改的确传输文件的大小和执行时间都能少很多

- name: 导入所有离线镜像
shell: ls /opt/kube/images/*.tar |while read n;do {{ bin_dir }}/docker load -i $n ;done
ignore_errors: true
when: "CONTAINER_RUNTIME == 'docker'"
- name: 导入所有离线镜像
shell: ls /opt/kube/images/*.tar |while read n;do {{ bin_dir }}/ctr -n=k8s.io images import $n ;done
ignore_errors: true
when: "CONTAINER_RUNTIME == 'containerd'"