kubeasz/roles/kube-router/tasks/main.yml

50 lines
1.6 KiB
YAML
Raw Normal View History

- name: 创建cni 和kube-router 相关目录
file: name={{ item }} state=directory
with_items:
- /etc/cni/net.d
- /opt/kube/kube-system/kube-router
- name: 下载cni plugins
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
with_items:
- bridge
- host-local
- loopback
- portmap
2018-06-14 21:38:39 +08:00
# kube-router 不带service proxy
- name: 准备配置 kube-router DaemonSet (without IPVS)
template: src=kuberouter.yaml.j2 dest=/opt/kube/kube-system/kube-router/kuberouter.yaml
2018-06-14 21:38:39 +08:00
when: 'SERVICE_PROXY == "kube-proxy"'
- name: 停止 kube-proxy 服务
shell: "systemctl stop kube-proxy.service && systemctl disable kube-proxy.service"
when: 'SERVICE_PROXY == "IPVS"'
ignore_errors: true
- name: 清理 kube-proxy产生的iptables规则
shell: "{{ bin_dir }}/kube-proxy --cleanup"
when: 'SERVICE_PROXY == "IPVS"'
ignore_errors: true
# kube-router 带service proxy (IPVS/LVS)
- name: 准备配置 kube-router DaemonSet (with IPVS)
template: src=kuberouter-all.yaml.j2 dest=/opt/kube/kube-system/kube-router/kuberouter.yaml
when: 'SERVICE_PROXY == "IPVS"'
- name: 获取所有已经创建的POD信息
command: "{{ bin_dir }}/kubectl get daemonset -n kube-system"
register: pod_info
run_once: true
# 只需单节点执行一次
2018-06-14 21:38:39 +08:00
- name: 运行 kube-router DaemonSet
shell: "{{ bin_dir }}/kubectl create -f /opt/kube/kube-system/kube-router/ && sleep 5"
run_once: true
when: '"kube-router" not in pod_info.stdout'
# 删除原有cni配置
- name: 删除默认cni配置
file: path=/etc/cni/net.d/10-default.conf state=absent