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
|
|
|
|
|
2020-04-11 14:48:03 +08:00
|
|
|
- name: Kubernetes Apps | Check AppArmor status
|
|
|
|
command: which apparmor_parser
|
|
|
|
register: apparmor_status
|
|
|
|
when:
|
|
|
|
- podsecuritypolicy_enabled
|
2021-03-24 08:26:05 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
2020-04-11 14:48:03 +08:00
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Set apparmor_enabled
|
|
|
|
set_fact:
|
|
|
|
apparmor_enabled: "{{ apparmor_status.rc == 0 }}"
|
|
|
|
when:
|
|
|
|
- podsecuritypolicy_enabled
|
2021-03-24 08:26:05 +08:00
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
2020-04-11 14:48:03 +08:00
|
|
|
|
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"
|
|
|
|
state: "{{ metallb_rendering.changed | ternary('latest','present') }}"
|
|
|
|
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
|
|
|
|
command: "{{ bin_dir }}/kubectl -n metallb-system wait --for=condition=ready pod -l app=metallb,component=controller"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
|
|
|
|
- name: MetalLB | Address pools
|
|
|
|
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"
|
|
|
|
state: "{{ pools_rendering.changed | ternary('latest','present') }}"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
- metallb_config.address_pools is defined
|
|
|
|
|
|
|
|
- name: MetalLB | Layer2
|
|
|
|
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"
|
|
|
|
state: "{{ layer2_rendering.changed | ternary('latest','present') }}"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
- metallb_config.layer2 is defined
|
|
|
|
|
|
|
|
- name: MetalLB | Layer3
|
|
|
|
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"
|
|
|
|
state: "{{ layer3_rendering.changed | ternary('latest','present') }}"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- inventory_hostname == groups['kube_control_plane'][0]
|
|
|
|
- metallb_config.layer3 is defined
|
|
|
|
|
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
|