2018-10-16 22:15:05 +08:00
|
|
|
---
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Create annotations
|
2023-06-26 18:15:45 +08:00
|
|
|
import_tasks: annotate.yml
|
2018-10-21 15:35:52 +08:00
|
|
|
tags: annotate
|
2018-10-16 22:15:05 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Create config directory
|
2020-03-04 18:11:47 +08:00
|
|
|
file:
|
|
|
|
path: /var/lib/kube-router
|
|
|
|
state: directory
|
2022-06-17 16:34:32 +08:00
|
|
|
owner: "{{ kube_owner }}"
|
2020-03-04 18:11:47 +08:00
|
|
|
recurse: true
|
|
|
|
mode: 0755
|
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Create kubeconfig
|
2020-03-04 18:11:47 +08:00
|
|
|
template:
|
|
|
|
src: kubeconfig.yml.j2
|
|
|
|
dest: /var/lib/kube-router/kubeconfig
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2022-06-17 16:34:32 +08:00
|
|
|
owner: "{{ kube_owner }}"
|
2020-03-04 18:11:47 +08:00
|
|
|
notify:
|
2023-07-26 22:36:22 +08:00
|
|
|
- Reset_kube_router
|
2020-03-04 18:11:47 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Slurp cni config
|
2020-03-04 18:11:47 +08:00
|
|
|
slurp:
|
2020-03-17 17:40:21 +08:00
|
|
|
src: /etc/cni/net.d/10-kuberouter.conflist
|
2020-03-04 18:11:47 +08:00
|
|
|
register: cni_config_slurp
|
2021-07-12 15:00:47 +08:00
|
|
|
ignore_errors: true # noqa ignore-errors
|
2020-03-04 18:11:47 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Set cni_config variable
|
2020-03-04 18:11:47 +08:00
|
|
|
set_fact:
|
|
|
|
cni_config: "{{ cni_config_slurp.content | b64decode | from_json }}"
|
|
|
|
when:
|
|
|
|
- not cni_config_slurp.failed
|
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Set host_subnet variable
|
2020-03-04 18:11:47 +08:00
|
|
|
when:
|
|
|
|
- cni_config is defined
|
2020-03-17 17:40:21 +08:00
|
|
|
- cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | length > 0
|
2023-08-10 15:57:27 +08:00
|
|
|
set_fact:
|
|
|
|
host_subnet: "{{ cni_config | json_query('plugins[?bridge==`kube-bridge`].ipam.subnet') | first }}"
|
2020-03-04 18:11:47 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Create cni config
|
2020-03-17 17:40:21 +08:00
|
|
|
template:
|
|
|
|
src: cni-conf.json.j2
|
|
|
|
dest: /etc/cni/net.d/10-kuberouter.conflist
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2022-06-17 16:34:32 +08:00
|
|
|
owner: "{{ kube_owner }}"
|
2020-03-04 18:11:47 +08:00
|
|
|
notify:
|
2023-07-26 22:36:22 +08:00
|
|
|
- Reset_kube_router
|
2020-03-04 18:11:47 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Delete old configuration
|
2020-03-17 17:40:21 +08:00
|
|
|
file:
|
|
|
|
path: /etc/cni/net.d/10-kuberouter.conf
|
|
|
|
state: absent
|
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Kube-router | Create manifest
|
2018-10-16 22:15:05 +08:00
|
|
|
template:
|
|
|
|
src: kube-router.yml.j2
|
2018-12-03 18:22:17 +08:00
|
|
|
dest: "{{ kube_config_dir }}/kube-router.yml"
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2021-03-24 08:26:05 +08:00
|
|
|
delegate_to: "{{ groups['kube_control_plane'] | first }}"
|
2020-03-04 18:11:47 +08:00
|
|
|
run_once: true
|