diff --git a/inventory/sample/group_vars/k8s-cluster/addons.yml b/inventory/sample/group_vars/k8s-cluster/addons.yml index eb292da97..9a3526795 100644 --- a/inventory/sample/group_vars/k8s-cluster/addons.yml +++ b/inventory/sample/group_vars/k8s-cluster/addons.yml @@ -132,6 +132,28 @@ cert_manager_enabled: false metallb_enabled: false # metallb_ip_range: # - "10.5.0.50-10.5.0.99" +# metallb_speaker_nodeselector: +# kubernetes.io/os: "linux" +# metallb_controller_nodeselector: +# kubernetes.io/os: "linux" +# metallb_speaker_tolerations: +# - key: "node-role.kubernetes.io/master" +# operator: "Equal" +# value: "" +# effect: "NoSchedule" +# - key: "node-role.kubernetes.io/control-plane" +# operator: "Equal" +# value: "" +# effect: "NoSchedule" +# metallb_controller_tolerations: +# - key: "node-role.kubernetes.io/master" +# operator: "Equal" +# value: "" +# effect: "NoSchedule" +# - key: "node-role.kubernetes.io/control-plane" +# operator: "Equal" +# value: "" +# effect: "NoSchedule" # metallb_version: v0.9.5 # metallb_protocol: "layer2" # metallb_port: "7472" diff --git a/roles/kubernetes-apps/metallb/defaults/main.yml b/roles/kubernetes-apps/metallb/defaults/main.yml index ae26ba3e1..c5aa0a7df 100644 --- a/roles/kubernetes-apps/metallb/defaults/main.yml +++ b/roles/kubernetes-apps/metallb/defaults/main.yml @@ -6,3 +6,11 @@ metallb_port: "7472" metallb_limits_cpu: "100m" metallb_limits_mem: "100Mi" metallb_peers: [] +metallb_speaker_nodeselector: {} +metallb_controller_nodeselector: {} +metallb_speaker_tolerations: + - effect: NoSchedule + key: node-role.kubernetes.io/master + - effect: NoSchedule + key: node-role.kubernetes.io/control-plane +metallb_controller_tolerations: [] diff --git a/roles/kubernetes-apps/metallb/templates/metallb.yml.j2 b/roles/kubernetes-apps/metallb/templates/metallb.yml.j2 index 4fe688365..29be2b1a3 100644 --- a/roles/kubernetes-apps/metallb/templates/metallb.yml.j2 +++ b/roles/kubernetes-apps/metallb/templates/metallb.yml.j2 @@ -345,11 +345,14 @@ spec: kubernetes.io/os: linux serviceAccountName: speaker terminationGracePeriodSeconds: 2 +{% if metallb_speaker_nodeselector %} + nodeSelector: + {{ metallb_speaker_nodeselector | to_nice_yaml | indent(width=8) }} +{%- endif %} +{% if metallb_speaker_tolerations %} tolerations: - - effect: NoSchedule - key: node-role.kubernetes.io/master - - effect: NoSchedule - key: node-role.kubernetes.io/control-plane + {{ metallb_speaker_tolerations | to_nice_yaml(indent=2) | indent(width=8) }} +{% endif %} --- apiVersion: apps/v1 kind: Deployment @@ -374,6 +377,14 @@ spec: app: metallb component: controller spec: +{% if metallb_controller_nodeselector %} + nodeSelector: + {{ metallb_controller_nodeselector | to_nice_yaml | indent(width=8) }} +{%- endif %} +{% if metallb_controller_tolerations %} + tolerations: + {{ metallb_controller_tolerations | to_nice_yaml(indent=2) | indent(width=8) }} +{% endif %} containers: - args: - --port={{ metallb_port }}