Skip to content

Commit

Permalink
Chart: podAntiAffinity for scheduler, webserver, and workers (#16315
Browse files Browse the repository at this point in the history
)

Set default podAntiAffinity for the components that can scale, as in
most cases you'd want them spread across available nodes.
  • Loading branch information
jedcunningham committed Jun 9, 2021
1 parent 36651be commit 24d2ce1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 6 deletions.
10 changes: 10 additions & 0 deletions chart/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ def test_should_create_valid_affinity_tolerations_and_node_selector(self):
docs[0],
)

def test_should_create_default_affinity(self):
docs = render_chart(show_only=["templates/scheduler/scheduler-deployment.yaml"])

assert {"component": "scheduler"} == jmespath.search(
"spec.template.spec.affinity.podAntiAffinity."
"preferredDuringSchedulingIgnoredDuringExecution[0]."
"podAffinityTerm.labelSelector.matchLabels",
docs[0],
)

def test_livenessprobe_values_are_configurable(self):
docs = render_chart(
values={
Expand Down
10 changes: 10 additions & 0 deletions chart/tests/test_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ def test_should_create_valid_affinity_tolerations_and_node_selector(self):
docs[0],
)

def test_should_create_default_affinity(self):
docs = render_chart(show_only=["templates/webserver/webserver-deployment.yaml"])

assert {"component": "webserver"} == jmespath.search(
"spec.template.spec.affinity.podAntiAffinity."
"preferredDuringSchedulingIgnoredDuringExecution[0]."
"podAffinityTerm.labelSelector.matchLabels",
docs[0],
)

@parameterized.expand(
[
({"enabled": False}, None),
Expand Down
10 changes: 10 additions & 0 deletions chart/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ def test_should_create_valid_affinity_tolerations_and_node_selector(self):
docs[0],
)

def test_should_create_default_affinity(self):
docs = render_chart(show_only=["templates/workers/worker-deployment.yaml"])

assert {"component": "worker"} == jmespath.search(
"spec.template.spec.affinity.podAntiAffinity."
"preferredDuringSchedulingIgnoredDuringExecution[0]."
"podAffinityTerm.labelSelector.matchLabels",
docs[0],
)

@parameterized.expand(
[
({"enabled": False}, {"emptyDir": {}}),
Expand Down
6 changes: 3 additions & 3 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@
"affinity": {
"description": "Specify scheduling constraints for worker pods.",
"type": "object",
"default": {}
"default": "See values.yaml"
},
"tolerations": {
"description": "Specify Tolerations for worker pods.",
Expand Down Expand Up @@ -1298,7 +1298,7 @@
"affinity": {
"description": "Specify scheduling constraints for scheduler pods.",
"type": "object",
"default": {}
"default": "See values.yaml"
},
"tolerations": {
"description": "Specify Tolerations for scheduler pods.",
Expand Down Expand Up @@ -1724,7 +1724,7 @@
"affinity": {
"description": "Specify scheduling constraints for webserver pods.",
"type": "object",
"default": {}
"default": "See values.yaml"
},
"tolerations": {
"description": "Specify Tolerations for webserver pods.",
Expand Down
30 changes: 27 additions & 3 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,15 @@ workers:

# Select certain nodes for airflow worker pods.
nodeSelector: {}
affinity: {}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
component: worker
topologyKey: "kubernetes.io/hostname"
tolerations: []
# hostAliases to use in worker pods.
# See:
Expand Down Expand Up @@ -507,7 +515,15 @@ scheduler:

# Select certain nodes for airflow scheduler pods.
nodeSelector: {}
affinity: {}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
component: scheduler
topologyKey: "kubernetes.io/hostname"
tolerations: []

logGroomerSidecar:
Expand Down Expand Up @@ -649,7 +665,15 @@ webserver:

# Select certain nodes for airflow webserver pods.
nodeSelector: {}
affinity: {}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
component: webserver
topologyKey: "kubernetes.io/hostname"
tolerations: []

# Flower settings
Expand Down

0 comments on commit 24d2ce1

Please sign in to comment.