Skip to content

Commit

Permalink
Add nodeselector and tolerations for metallb (kubernetes-sigs#7334)
Browse files Browse the repository at this point in the history
* add nodeselector and tolerations for metallb

* remove unnecessary commented lines in metallb template

* set default speaker toleration to match original manifest
  • Loading branch information
francoishernandez authored Mar 8, 2021
1 parent dc5df57 commit c7db72e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
22 changes: 22 additions & 0 deletions inventory/sample/group_vars/k8s-cluster/addons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions roles/kubernetes-apps/metallb/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
19 changes: 15 additions & 4 deletions roles/kubernetes-apps/metallb/templates/metallb.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down

0 comments on commit c7db72e

Please sign in to comment.