2022-10-09 19:24:44 +08:00
|
|
|
- block:
|
|
|
|
- name: 注册变量 ovn_default_gateway
|
|
|
|
shell: echo {{ CLUSTER_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+1}'
|
|
|
|
register: ovn_default_gateway
|
|
|
|
|
|
|
|
- name: 设置变量 kube_ovn_default_gateway
|
|
|
|
set_fact: kube_ovn_default_gateway={{ ovn_default_gateway.stdout }}
|
|
|
|
|
|
|
|
- name: 创建配置文件
|
|
|
|
template: src={{ item }}.j2 dest={{ cluster_dir }}/yml/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- crd.yaml
|
|
|
|
- kube-ovn.yaml
|
|
|
|
- ovn.yaml
|
|
|
|
|
2022-11-27 20:42:58 +08:00
|
|
|
- name: 删除 kube-ovn网络
|
|
|
|
shell: "{{ base_dir }}/bin/kubectl delete -f {{ cluster_dir }}/yml/crd.yaml; \
|
|
|
|
{{ base_dir }}/bin/kubectl delete -f {{ cluster_dir }}/yml/ovn.yaml; \
|
|
|
|
{{ base_dir }}/bin/kubectl delete -f {{ cluster_dir }}/yml/kube-ovn.yaml; sleep 3"
|
|
|
|
tags: force_change_certs
|
|
|
|
when: 'CHANGE_CA|bool'
|
|
|
|
|
2022-10-09 19:24:44 +08:00
|
|
|
- name: 运行 kube-ovn网络
|
|
|
|
shell: "{{ base_dir }}/bin/kubectl label node {{ OVN_DB_NODE }} kube-ovn/role=master --overwrite && \
|
|
|
|
{{ base_dir }}/bin/kubectl apply -f {{ cluster_dir }}/yml/crd.yaml && sleep 5 && \
|
|
|
|
{{ base_dir }}/bin/kubectl apply -f {{ cluster_dir }}/yml/ovn.yaml && sleep 5 && \
|
|
|
|
{{ base_dir }}/bin/kubectl apply -f {{ cluster_dir }}/yml/kube-ovn.yaml"
|
2022-11-27 20:42:58 +08:00
|
|
|
tags: force_change_certs
|
2019-05-22 11:17:42 +08:00
|
|
|
run_once: true
|
2022-10-09 19:24:44 +08:00
|
|
|
connection: local
|
2019-05-22 11:17:42 +08:00
|
|
|
|
|
|
|
# 删除原有cni配置
|
|
|
|
- name: 删除默认cni配置
|
|
|
|
file: path=/etc/cni/net.d/10-default.conf state=absent
|
|
|
|
|
2022-10-09 19:24:44 +08:00
|
|
|
- name: 配置 kubectl plugin
|
|
|
|
template: src=kubectl-ko.j2 dest=/usr/local/bin/kubectl-ko mode=0755
|
|
|
|
|
2019-05-22 11:17:42 +08:00
|
|
|
# 等待网络插件部署成功,视下载镜像速度而定
|
|
|
|
- name: 轮询等待kube-ovn 运行,视下载镜像速度而定
|
2023-01-15 21:41:45 +08:00
|
|
|
shell: "{{ base_dir }}/bin/kubectl get pod -n kube-ovn -o wide|grep 'kube-ovn-cni'|grep ' {{ K8S_NODENAME }} '|awk '{print $3}'"
|
2019-05-22 11:17:42 +08:00
|
|
|
register: pod_status
|
|
|
|
until: pod_status.stdout == "Running"
|
|
|
|
retries: 15
|
|
|
|
delay: 8
|
|
|
|
ignore_errors: true
|
2022-10-09 19:24:44 +08:00
|
|
|
connection: local
|
2022-11-27 20:42:58 +08:00
|
|
|
tags: force_change_certs
|