From 12fe1a56bd9a3e24b0a616330750d3fa4538a920 Mon Sep 17 00:00:00 2001 From: Sheogorath <sheogorath@shivering-isles.com> Date: Thu, 5 Jan 2023 19:03:20 +0000 Subject: [PATCH] fix(mastodon): Unify affinities for jobs Currently the jobs still had the old S3 dependant affinity magic going, which seems violates the rule of least surprise (in my perspective), therefore removing the magic affinity adjustments and instead go with using the same affinities defined for all web Pods. --- .../templates/job-assets-precompile.yaml | 16 +++------------- charts/mastodon/templates/job-chewy-upgrade.yaml | 16 +++------------- charts/mastodon/templates/job-create-admin.yaml | 16 +++------------- charts/mastodon/templates/job-db-migrate.yaml | 16 +++------------- 4 files changed, 12 insertions(+), 52 deletions(-) diff --git a/charts/mastodon/templates/job-assets-precompile.yaml b/charts/mastodon/templates/job-assets-precompile.yaml index bc5ff7bfb..95019629c 100644 --- a/charts/mastodon/templates/job-assets-precompile.yaml +++ b/charts/mastodon/templates/job-assets-precompile.yaml @@ -18,21 +18,11 @@ spec: {{- end }} spec: restartPolicy: Never - {{- if (not .Values.mastodon.s3.enabled) }} - # ensure we run on the same node as the other rails components; only - # required when using PVCs that are ReadWriteOnce - {{- if or (eq "ReadWriteOnce" .Values.mastodon.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.mastodon.persistence.system.accessMode) }} + {{- with (default .Values.affinity .Values.mastodon.web.affinity) }} affinity: - podAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app.kubernetes.io/part-of - operator: In - values: - - rails - topologyKey: kubernetes.io/hostname + {{- toYaml . | nindent 8 }} {{- end }} + {{- if (not .Values.mastodon.s3.enabled) }} volumes: - name: assets persistentVolumeClaim: diff --git a/charts/mastodon/templates/job-chewy-upgrade.yaml b/charts/mastodon/templates/job-chewy-upgrade.yaml index f86a4e34f..1ecb00518 100644 --- a/charts/mastodon/templates/job-chewy-upgrade.yaml +++ b/charts/mastodon/templates/job-chewy-upgrade.yaml @@ -19,21 +19,11 @@ spec: {{- end }} spec: restartPolicy: Never - {{- if (not .Values.mastodon.s3.enabled) }} - # ensure we run on the same node as the other rails components; only - # required when using PVCs that are ReadWriteOnce - {{- if or (eq "ReadWriteOnce" .Values.mastodon.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.mastodon.persistence.system.accessMode) }} + {{- with (default .Values.affinity .Values.mastodon.web.affinity) }} affinity: - podAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app.kubernetes.io/part-of - operator: In - values: - - rails - topologyKey: kubernetes.io/hostname + {{- toYaml . | nindent 8 }} {{- end }} + {{- if (not .Values.mastodon.s3.enabled) }} volumes: - name: assets persistentVolumeClaim: diff --git a/charts/mastodon/templates/job-create-admin.yaml b/charts/mastodon/templates/job-create-admin.yaml index 3d137f5c7..2338e3738 100644 --- a/charts/mastodon/templates/job-create-admin.yaml +++ b/charts/mastodon/templates/job-create-admin.yaml @@ -19,21 +19,11 @@ spec: {{- end }} spec: restartPolicy: Never - {{- if (not .Values.mastodon.s3.enabled) }} - # ensure we run on the same node as the other rails components; only - # required when using PVCs that are ReadWriteOnce - {{- if or (eq "ReadWriteOnce" .Values.mastodon.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.mastodon.persistence.system.accessMode) }} + {{- with (default .Values.affinity .Values.mastodon.web.affinity) }} affinity: - podAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app.kubernetes.io/part-of - operator: In - values: - - rails - topologyKey: kubernetes.io/hostname + {{- toYaml . | nindent 8 }} {{- end }} + {{- if (not .Values.mastodon.s3.enabled) }} volumes: - name: assets persistentVolumeClaim: diff --git a/charts/mastodon/templates/job-db-migrate.yaml b/charts/mastodon/templates/job-db-migrate.yaml index 41324fbd0..5ccf5b996 100644 --- a/charts/mastodon/templates/job-db-migrate.yaml +++ b/charts/mastodon/templates/job-db-migrate.yaml @@ -18,21 +18,11 @@ spec: {{- end }} spec: restartPolicy: Never - {{- if (not .Values.mastodon.s3.enabled) }} - # ensure we run on the same node as the other rails components; only - # required when using PVCs that are ReadWriteOnce - {{- if or (eq "ReadWriteOnce" .Values.mastodon.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.mastodon.persistence.system.accessMode) }} + {{- with (default .Values.affinity .Values.mastodon.web.affinity) }} affinity: - podAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app.kubernetes.io/part-of - operator: In - values: - - rails - topologyKey: kubernetes.io/hostname + {{- toYaml . | nindent 8 }} {{- end }} + {{- if (not .Values.mastodon.s3.enabled) }} volumes: - name: assets persistentVolumeClaim: -- GitLab