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
|
|
|
|
2020-08-05 16:52:40 +08:00
|
|
|
- name: Kubernetes Apps | Check BGP peers for MetalLB
|
|
|
|
fail:
|
2022-02-23 15:12:18 +08:00
|
|
|
msg: "metallb_peers is mandatory when metallb_protocol is bgp and metallb_speaker_enabled"
|
2020-08-05 16:52:40 +08:00
|
|
|
when:
|
2023-04-14 16:14:41 +08:00
|
|
|
- metallb_config.layer3 is defined and metallb_speaker_enabled
|
|
|
|
- metallb_config.metallb_peers is not defined or not metallb_config.metallb_peers
|
2020-08-05 16:52:40 +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:
|
|
|
|
src: "{{ item }}.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/{{ item }}"
|
|
|
|
mode: 0644
|
2023-05-09 08:20:52 +08:00
|
|
|
with_items: ["metallb.yml", "pools.yaml", "layer2.yaml", "layer3.yaml"]
|
2018-09-04 20:17:23 +08:00
|
|
|
register: "rendering"
|
|
|
|
when:
|
2021-03-24 08:26:05 +08:00
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|
2020-04-11 14:48:03 +08:00
|
|
|
|
2023-04-14 16:14:41 +08:00
|
|
|
- name: Kubernetes Apps | Create MetalLB resources and replace existing
|
|
|
|
k8s:
|
|
|
|
definition: "{{ lookup('template', 'metallb.yaml') }}"
|
|
|
|
|
|
|
|
- name: Kubernetes Apps | Wait for MetalLB controller to be running
|
|
|
|
k8s_info:
|
|
|
|
kind: Deployment
|
|
|
|
namespace: metallb-system
|
|
|
|
name: controller
|
|
|
|
wait: True
|
|
|
|
wait_sleep: 10
|
|
|
|
wait_timeout: 360
|
|
|
|
wait_condition:
|
|
|
|
status: "True"
|
|
|
|
type: Available
|
|
|
|
register: result
|
|
|
|
until: result is not failed
|
|
|
|
|
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"
|
2019-04-24 01:37:23 +08:00
|
|
|
filename: "{{ kube_config_dir }}/{{ item.item }}"
|
2018-09-04 20:17:23 +08:00
|
|
|
state: "{{ item.changed | ternary('latest','present') }}"
|
2019-03-18 09:15:09 +08:00
|
|
|
become: true
|
2019-04-24 01:37:23 +08:00
|
|
|
with_items: "{{ rendering.results }}"
|
2018-09-04 20:17:23 +08:00
|
|
|
when:
|
2021-03-24 08:26:05 +08:00
|
|
|
- "inventory_hostname == groups['kube_control_plane'][0]"
|
2023-04-14 16:14:41 +08:00
|
|
|
|
|
|
|
- name: Kubernetes Apps | Delete MetalLB ConfigMap
|
|
|
|
k8s:
|
|
|
|
name: config
|
|
|
|
kind: ConfigMap
|
|
|
|
namespace: metallb-system
|
|
|
|
state: absent
|