2018-09-04 20:17:23 +08:00
|
|
|
---
|
2021-04-11 15:37:59 +08:00
|
|
|
- name: Kubernetes Apps | Check cluster settings for MetalLB
|
2019-09-26 19:21:06 +08:00
|
|
|
fail:
|
|
|
|
msg: "MetalLB require kube_proxy_strict_arp = true, see https://github.com/danderson/metallb/issues/153#issuecomment-518651132"
|
|
|
|
when:
|
|
|
|
- "kube_proxy_mode == 'ipvs' and not kube_proxy_strict_arp"
|
2020-04-11 14:48:03 +08:00
|
|
|
|
2022-06-14 00:40:12 +08:00
|
|
|
- name: Kubernetes Apps | Check that the deprecated 'matallb_auto_assign' variable is not used anymore
|
|
|
|
fail:
|
|
|
|
msg: "'matallb_auto_assign' configuration variable is deprecated, please use 'metallb_auto_assign' instead"
|
|
|
|
when:
|
|
|
|
- matallb_auto_assign is defined
|
|
|
|
|
2021-04-11 15:37:59 +08:00
|
|
|
- name: Kubernetes Apps | Lay Down MetalLB
|
2018-09-04 20:17:23 +08:00
|
|
|
become: true
|
2022-01-09 17:51:12 +08:00
|
|
|
template:
|
2023-05-31 02:37:49 +08:00
|
|
|
src: "metallb.yaml.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/metallb.yaml"
|
2022-01-09 17:51:12 +08:00
|
|
|
mode: 0644
|
2023-05-31 02:37:49 +08:00
|
|
|
register: metallb_rendering
|
2018-09-04 20:17:23 +08:00
|
|
|
when:
|
2023-05-31 02:37:49 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
2023-04-14 16:14:41 +08:00
|
|
|
|
2021-04-11 15:37:59 +08:00
|
|
|
- name: Kubernetes Apps | Install and configure MetalLB
|
2018-09-04 20:17:23 +08:00
|
|
|
kube:
|
2019-04-24 01:37:23 +08:00
|
|
|
name: "MetalLB"
|
2019-05-03 05:24:21 +08:00
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
2023-05-31 02:37:49 +08:00
|
|
|
filename: "{{ kube_config_dir }}/metallb.yaml"
|
2023-07-05 11:36:54 +08:00
|
|
|
state: "{{ metallb_rendering.changed | ternary('latest', 'present') }}"
|
2023-05-31 02:37:49 +08:00
|
|
|
wait: true
|
2019-03-18 09:15:09 +08:00
|
|
|
become: true
|
2018-09-04 20:17:23 +08:00
|
|
|
when:
|
2023-05-31 02:37:49 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Wait for MetalLB controller to be running
|
2023-06-28 11:54:32 +08:00
|
|
|
command: "{{ bin_dir }}/kubectl -n metallb-system wait --for=condition=ready pod -l app=metallb,component=controller --timeout=2m"
|
2023-05-31 02:37:49 +08:00
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
|
|
|
|
- name: MetalLB | Address pools
|
2023-08-10 15:57:27 +08:00
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
- metallb_config.address_pools is defined
|
2023-05-31 02:37:49 +08:00
|
|
|
block:
|
|
|
|
- name: MetalLB | Layout address pools template
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: pools.yaml.j2
|
|
|
|
dest: "{{ kube_config_dir }}/pools.yaml"
|
|
|
|
mode: 0644
|
|
|
|
register: pools_rendering
|
|
|
|
|
|
|
|
- name: MetalLB | Create address pools configuration
|
|
|
|
kube:
|
|
|
|
name: "MetalLB"
|
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
|
|
|
filename: "{{ kube_config_dir }}/pools.yaml"
|
2023-07-05 11:36:54 +08:00
|
|
|
state: "{{ pools_rendering.changed | ternary('latest', 'present') }}"
|
2023-05-31 02:37:49 +08:00
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: MetalLB | Layer2
|
2023-08-10 15:57:27 +08:00
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
- metallb_config.layer2 is defined
|
2023-05-31 02:37:49 +08:00
|
|
|
block:
|
|
|
|
- name: MetalLB | Layout layer2 template
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: layer2.yaml.j2
|
|
|
|
dest: "{{ kube_config_dir }}/layer2.yaml"
|
|
|
|
mode: 0644
|
|
|
|
register: layer2_rendering
|
|
|
|
|
|
|
|
- name: MetalLB | Create layer2 configuration
|
|
|
|
kube:
|
|
|
|
name: "MetalLB"
|
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
|
|
|
filename: "{{ kube_config_dir }}/layer2.yaml"
|
2023-07-05 11:36:54 +08:00
|
|
|
state: "{{ layer2_rendering.changed | ternary('latest', 'present') }}"
|
2023-05-31 02:37:49 +08:00
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: MetalLB | Layer3
|
2023-08-10 15:57:27 +08:00
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
- metallb_config.layer3 is defined
|
2023-05-31 02:37:49 +08:00
|
|
|
block:
|
|
|
|
- name: MetalLB | Layout layer3 template
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: layer3.yaml.j2
|
|
|
|
dest: "{{ kube_config_dir }}/layer3.yaml"
|
|
|
|
mode: 0644
|
|
|
|
register: layer3_rendering
|
|
|
|
|
|
|
|
- name: MetalLB | Create layer3 configuration
|
|
|
|
kube:
|
|
|
|
name: "MetalLB"
|
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
|
|
|
filename: "{{ kube_config_dir }}/layer3.yaml"
|
2023-07-05 11:36:54 +08:00
|
|
|
state: "{{ layer3_rendering.changed | ternary('latest', 'present') }}"
|
2023-05-31 02:37:49 +08:00
|
|
|
become: true
|
|
|
|
|
2023-04-14 16:14:41 +08:00
|
|
|
|
|
|
|
- name: Kubernetes Apps | Delete MetalLB ConfigMap
|
2023-05-31 02:37:49 +08:00
|
|
|
kube:
|
2023-04-14 16:14:41 +08:00
|
|
|
name: config
|
2023-05-31 02:37:49 +08:00
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
|
|
|
resource: ConfigMap
|
2023-04-14 16:14:41 +08:00
|
|
|
namespace: metallb-system
|
|
|
|
state: absent
|