Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podAntiAffinity for scheduler, webserver, and workers #16315

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -1678,7 +1678,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 @@ -637,7 +653,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