Skip to content

Commit

Permalink
更新tools/change_k8s_network.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Sep 25, 2018
1 parent c366125 commit c53768a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
2 changes: 2 additions & 0 deletions 90.setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@
tasks:
- name: 禁止业务 pod调度到 master节点
shell: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }} "
delegate_to: "{{ groups.deploy[0] }}"
when: DEPLOY_MODE != "allinone"
ignore_errors: true

- name: 设置master节点role
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=master --overwrite"
ignore_errors: true
delegate_to: "{{ groups.deploy[0] }}"

# node 节点部署
- hosts: kube-node
Expand Down
35 changes: 10 additions & 25 deletions tools/change_k8s_network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,20 @@
- name: 获取所有已经创建的POD信息
command: "{{ bin_dir }}/kubectl get daemonset -n kube-system"
register: pod_info
delegate_to: "{{ groups.deploy[0] }}"
run_once: true

- name: 删除原network插件calico部署
shell: "{{ bin_dir }}/kubectl delete -f /opt/kube/kube-system/calico/ || \
{{ bin_dir }}/kubectl delete -f /root/local/kube-system/calico/"
ignore_errors: true
run_once: true
when: '"calico" in pod_info.stdout'

- name: 删除原network插件cilium部署
shell: "{{ bin_dir }}/kubectl delete -f /opt/kube/kube-system/cilium/ || \
{{ bin_dir }}/kubectl delete -f /root/local/kube-system/cilium/"
ignore_errors: true
run_once: true
when: '"cilium" in pod_info.stdout'

- name: 删除原network插件flannel部署
shell: "{{ bin_dir }}/kubectl delete -f /opt/kube/kube-system/flannel/ || \
{{ bin_dir }}/kubectl delete -f /root/local/kube-system/flannel/"
ignore_errors: true
- name: 删除原network插件部署
shell: "{{ bin_dir }}/kubectl delete -f /opt/kube/kube-system/{{ item }}/"
with_items:
- calico
- cilium
- flannel
- kube-router
when: 'item in pod_info.stdout'
delegate_to: "{{ groups.deploy[0] }}"
run_once: true
when: '"flannel" in pod_info.stdout'

- name: 删除原network插件kube-router部署
shell: "{{ bin_dir }}/kubectl delete -f /opt/kube/kube-system/kube-router/ || \
{{ bin_dir }}/kubectl delete -f /root/local/kube-system/kube-router/"
ignore_errors: true
run_once: true
when: '"kube-router" in pod_info.stdout'

- name: 清理kube-router相关
shell: "{{ bin_dir }}/docker run --privileged --net=host cloudnativelabs/kube-router --cleanup-config"
Expand Down

0 comments on commit c53768a

Please sign in to comment.