From 740ed27cc359789d5561898bf3d70d05df32218c Mon Sep 17 00:00:00 2001 From: Yann Defretin Date: Fri, 29 Sep 2023 17:30:42 +0200 Subject: [PATCH 1/2] Allow custom nodeSelector for each resource --- Chart.lock | 4 +- Chart.yaml | 2 +- templates/cronjob-media-remove.yaml | 4 + templates/deployment-sidekiq.yaml | 6 +- templates/deployment-streaming.yaml | 4 +- templates/deployment-web.yaml | 4 +- templates/job-assets-precompile.yaml | 4 + templates/job-chewy-upgrade.yaml | 4 + templates/job-create-admin.yaml | 4 + templates/job-db-migrate.yaml | 5 ++ values.yaml | 106 ++++++++++++++++++++------- 11 files changed, 112 insertions(+), 35 deletions(-) diff --git a/Chart.lock b/Chart.lock index 961e4fa..188cb6f 100644 --- a/Chart.lock +++ b/Chart.lock @@ -8,5 +8,5 @@ dependencies: - name: redis repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami version: 16.13.2 -digest: sha256:17ea58a3264aa22faff18215c4269f47dabae956d0df273c684972f356416193 -generated: "2022-08-08T21:44:18.0195364+02:00" +digest: sha256:8be2c8069d65f295d0079bdda67c45691370f7bef73393c2e80eedbdd748b9af +generated: "2023-09-29T16:46:40.462499+02:00" diff --git a/Chart.yaml b/Chart.yaml index 1ebc973..2b521fd 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -20,7 +20,7 @@ version: 4.0.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: v4.0.2 +appVersion: v4.2.0 dependencies: - name: elasticsearch diff --git a/templates/cronjob-media-remove.yaml b/templates/cronjob-media-remove.yaml index d70afeb..4076131 100644 --- a/templates/cronjob-media-remove.yaml +++ b/templates/cronjob-media-remove.yaml @@ -86,4 +86,8 @@ spec: - name: system mountPath: /opt/mastodon/public/system {{- end }} + {{- if .Values.mastodon.cron.removeMedia.nodeSelector }} + nodeSelector: + {{ .Values.mastodon.cron.removeMedia.nodeSelector | toYaml | nindent 12 }} + {{- end }} {{- end }} diff --git a/templates/deployment-sidekiq.yaml b/templates/deployment-sidekiq.yaml index 5dc9244..0f595a0 100644 --- a/templates/deployment-sidekiq.yaml +++ b/templates/deployment-sidekiq.yaml @@ -35,7 +35,7 @@ spec: {{- end }} # roll the pods to pick up any db migrations or other changes {{- include "mastodon.rollingPodAnnotations" $context | nindent 8 }} - checksum/config-secrets: {{ include ( print $.Template.BasePath "/secret-smtp.yaml" ) $context | sha256sum | quote }} + checksum/config-secrets-smtp: {{ include ( print $.Template.BasePath "/secret-smtp.yaml" ) $context | sha256sum | quote }} labels: {{- include "mastodon.selectorLabels" $context | nindent 8 }} app.kubernetes.io/component: sidekiq-{{ .name }} @@ -127,9 +127,9 @@ spec: {{- end }} resources: {{- toYaml (default (default $context.Values.resources $context.Values.mastodon.sidekiq.resources) .resources) | nindent 12 }} - {{- with $context.Values.nodeSelector }} + {{- if $context.Values.mastodon.sidekiq.nodeSelector }} nodeSelector: - {{- toYaml . | nindent 8 }} + {{- $context.Values.mastodon.sidekiq.nodeSelector | toYaml | nindent 8 }} {{- end }} {{- with $context.Values.tolerations }} tolerations: diff --git a/templates/deployment-streaming.yaml b/templates/deployment-streaming.yaml index ea08b1b..477b9a2 100644 --- a/templates/deployment-streaming.yaml +++ b/templates/deployment-streaming.yaml @@ -78,9 +78,9 @@ spec: resources: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.nodeSelector }} + {{- if .Values.mastodon.streaming.nodeSelector }} nodeSelector: - {{- toYaml . | nindent 8 }} + {{ .Values.mastodon.streaming.nodeSelector | toYaml | nindent 8 }} {{- end }} {{- with (default .Values.affinity .Values.mastodon.streaming.affinity) }} affinity: diff --git a/templates/deployment-web.yaml b/templates/deployment-web.yaml index 420c277..0752c1b 100644 --- a/templates/deployment-web.yaml +++ b/templates/deployment-web.yaml @@ -134,9 +134,9 @@ spec: resources: {{- toYaml . | nindent 12 }} {{- end }} - {{- with .Values.nodeSelector }} + {{- if .Values.mastodon.web.nodeSelector }} nodeSelector: - {{- toYaml . | nindent 8 }} + {{ .Values.mastodon.web.nodeSelector | toYaml | nindent 8 }} {{- end }} {{- with (default .Values.affinity .Values.mastodon.web.affinity) }} affinity: diff --git a/templates/job-assets-precompile.yaml b/templates/job-assets-precompile.yaml index bc5ff7b..9f67387 100644 --- a/templates/job-assets-precompile.yaml +++ b/templates/job-assets-precompile.yaml @@ -75,3 +75,7 @@ spec: - name: system mountPath: /opt/mastodon/public/system {{- end }} + {{- if .Values.mastodon.assetsPrecompile.nodeSelector }} + nodeSelector: + {{ .Values.mastodon.assetsPrecompile.nodeSelector | toYaml | nindent 8 }} + {{- end }} diff --git a/templates/job-chewy-upgrade.yaml b/templates/job-chewy-upgrade.yaml index f86a4e3..094ea08 100644 --- a/templates/job-chewy-upgrade.yaml +++ b/templates/job-chewy-upgrade.yaml @@ -76,4 +76,8 @@ spec: - name: system mountPath: /opt/mastodon/public/system {{- end }} + {{- if .Values.mastodon.chewyUpgrade.nodeSelector }} + nodeSelector: + {{ .Values.mastodon.chewyUpgrade.nodeSelector | toYaml | nindent 8 }} + {{- end }} {{- end }} diff --git a/templates/job-create-admin.yaml b/templates/job-create-admin.yaml index 3d137f5..02c3585 100644 --- a/templates/job-create-admin.yaml +++ b/templates/job-create-admin.yaml @@ -81,4 +81,8 @@ spec: - name: system mountPath: /opt/mastodon/public/system {{- end }} + {{- if .Values.mastodon.createAdmin.nodeSelector }} + nodeSelector: + {{ .Values.mastodon.createAdmin.nodeSelector | toYaml | nindent 8 }} + {{- end }} {{- end }} diff --git a/templates/job-db-migrate.yaml b/templates/job-db-migrate.yaml index 41324fb..7f2d9c8 100644 --- a/templates/job-db-migrate.yaml +++ b/templates/job-db-migrate.yaml @@ -75,3 +75,8 @@ spec: - name: system mountPath: /opt/mastodon/public/system {{- end }} + + {{ if .Values.mastodon.dbMigrate.nodeSelector }} + nodeSelector: + {{ .Values.mastodon.dbMigrate.nodeSelector | toYaml | nindent 8 }} + {{- end }} diff --git a/values.yaml b/values.yaml index a4660e2..2eb2561 100644 --- a/values.yaml +++ b/values.yaml @@ -20,6 +20,9 @@ mastodon: username: not_gargron # @ignored email: not@example.com + + # Node(s) on which we will deploy this resource + nodeSelector: {} cron: # -- run `tootctl media remove` every week removeMedia: @@ -27,7 +30,10 @@ mastodon: enabled: true # @ignored schedule: "0 0 * * 0" - # -- available locales: https://github.com/mastodon/mastodon/blob/main/config/application.rb#L71 + + # Node(s) on which we will deploy this resource + nodeSelector: {} + # -- available locales: https://github.com/mastodon/mastodon/blob/main/config/application.rb#L71 locale: en local_domain: mastodon.local # -- Use of WEB_DOMAIN requires careful consideration: https://docs.joinmastodon.org/admin/config/#federation @@ -94,25 +100,30 @@ mastodon: # requests: # cpu: 250m # memory: 512Mi + # Node(s) on which we will deploy this resource + nodeSelector: {} workers: - - name: all-queues - # -- Number of threads / parallel sidekiq jobs that are executed per Pod - concurrency: 25 - # -- Number of Pod replicas deployed by the Deployment - replicas: 1 - # -- Resources for this specific deployment to allow optimised scaling, overwrites .Values.mastodon.sidekiq.resources - resources: {} - # -- Affinity for this specific deployment, overwrites .Values.affinity and .Values.mastodon.sidekiq.affinity - affinity: {} - # -- Sidekiq queues for Mastodon that are handled by this worker. See https://docs.joinmastodon.org/admin/scaling/#concurrency - # See https://github.com/mperham/sidekiq/wiki/Advanced-Options#queues for how to weight queues as argument - queues: - - default,8 - - push,6 - - ingress,4 - - mailers,2 - - pull - - scheduler # Make sure the scheduler queue only exists once and with a worker that has 1 replica. + - name: all-queues + # -- Number of threads / parallel sidekiq jobs that are executed per Pod + concurrency: 25 + # -- Number of Pod replicas deployed by the Deployment + replicas: 1 + # -- Resources for this specific deployment to allow optimised scaling, overwrites .Values.mastodon.sidekiq.resources + resources: {} + # -- Affinity for this specific deployment, overwrites .Values.affinity and .Values.mastodon.sidekiq.affinity + affinity: {} + + # -- Node(s) on which we will deploy this resource + nodeSelector: {} + # -- Sidekiq queues for Mastodon that are handled by this worker. See https://docs.joinmastodon.org/admin/scaling/#concurrency + # See https://github.com/mperham/sidekiq/wiki/Advanced-Options#queues for how to weight queues as argument + queues: + - default,8 + - push,6 + - ingress,4 + - mailers,2 + - pull + - scheduler # Make sure the scheduler queue only exists once and with a worker that has 1 replica. #- name: push-pull # concurrency: 50 # resources: {} @@ -135,7 +146,7 @@ mastodon: ca_file: /etc/ssl/certs/ca-certificates.crt delivery_method: smtp domain: - enable_starttls: 'auto' + enable_starttls: "auto" from_address: notifications@example.com return_path: openssl_verify_mode: peer @@ -173,6 +184,9 @@ mastodon: # requests: # cpu: 250m # memory: 128Mi + + # -- Node(s) on which we will deploy this resource + nodeSelector: {} web: port: 3000 # -- Number of Web Pods running @@ -191,13 +205,30 @@ mastodon: # requests: # cpu: 250m # memory: 768Mi + + # -- Node(s) on which we will deploy this resource + nodeSelector: {} + # -- Puma-specific options. Below values are based on default behavior in # config/puma.rb when no custom values are provided. + minThreads: "5" maxThreads: "5" workers: "2" persistentTimeout: "20" + assetsPrecompile: + # Node(s) on which we will deploy this resource + nodeSelector: {} + + chewyUpgrade: + # Node(s) on which we will deploy this resource + nodeSelector: {} + + dbMigrate: + # Node(s) on which we will deploy this resource + nodeSelector: {} + metrics: statsd: # -- Enable statsd publishing via STATSD_ADDR environment variable @@ -226,7 +257,7 @@ ingress: hosts: - host: mastodon.local paths: - - path: '/' + - path: "/" tls: - secretName: mastodon-tls hosts: @@ -245,6 +276,18 @@ elasticsearch: image: tag: 7 + # -- Node(s) on which we will deploy this resource + master: + nodeSelector: {} + data: + nodeSelector: {} + coordinating: + nodeSelector: {} + ingest: + nodeSelector: {} + metrics: + nodeSelector: {} + # https://github.com/bitnami/charts/tree/master/bitnami/postgresql#parameters postgresql: # -- disable if you want to use an existing db; in which case the values below @@ -267,6 +310,15 @@ postgresql: # with a key of password set to the password you want existingSecret: "" + # -- Node(s) on which we will deploy this resource + primary: + nodeSelector: {} + readReplicas: + nodeSelector: {} + backup: + cronjob: + nodeSelector: {} + # https://github.com/bitnami/charts/tree/master/bitnami/redis#parameters redis: # disable if you want to use an existing redis instance; in which case the @@ -282,6 +334,12 @@ redis: # with a key of redis-password set to the password you want # existingSecret: "" + # -- Node(s) on which we will deploy this resource + master: + nodeSelector: {} + replica: + nodeSelector: {} + # @ignored service: type: ClusterIP @@ -425,7 +483,8 @@ revisionPodAnnotation: true jobAnnotations: {} # -- Default resources for all Deployments and jobs unless overwritten -resources: {} +resources: + {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little # resources, such as Minikube. If you do want to specify resources, uncomment the following @@ -437,9 +496,6 @@ resources: {} # cpu: 100m # memory: 128Mi -# @ignored -nodeSelector: {} - # @ignored tolerations: [] From 25084a82a8e4ae8bbd4eb30c9b362db75dead495 Mon Sep 17 00:00:00 2001 From: Yann Defretin Date: Wed, 20 Dec 2023 11:45:21 +0100 Subject: [PATCH 2/2] Update Nginx client max body size --- values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/values.yaml b/values.yaml index 2eb2561..ed09a8e 100644 --- a/values.yaml +++ b/values.yaml @@ -249,9 +249,9 @@ ingress: # # ensure that NGINX's upload size matches Mastodon's # for the K8s ingress controller: - # nginx.ingress.kubernetes.io/proxy-body-size: 40m + nginx.ingress.kubernetes.io/proxy-body-size: 90m # for the NGINX ingress controller: - # nginx.org/client-max-body-size: 40m + nginx.org/client-max-body-size: 90m # -- you can specify the ingressClassName if it differs from the default ingressClassName: hosts: