deployment-web.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: {{ include "mastodon.fullname" . }}-web
  5. labels:
  6. {{- include "mastodon.labels" . | nindent 4 }}
  7. {{- with .Values.mastodon.web.labels }}
  8. {{- toYaml . | nindent 4 }}
  9. {{- end }}
  10. annotations:
  11. {{- with .Values.deploymentAnnotations }}
  12. {{- toYaml . | nindent 4 }}
  13. {{- end }}
  14. {{- with .Values.mastodon.web.annotations }}
  15. {{- toYaml . | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. replicas: {{ .Values.mastodon.web.replicas }}
  19. {{- if (ne (toString .Values.mastodon.revisionHistoryLimit) "<nil>") }}
  20. revisionHistoryLimit: {{ .Values.mastodon.revisionHistoryLimit }}
  21. {{- end }}
  22. {{- if .Values.mastodon.web.updateStrategy }}
  23. strategy: {{- toYaml .Values.mastodon.web.updateStrategy | nindent 4 }}
  24. {{- end }}
  25. selector:
  26. matchLabels:
  27. {{- include "mastodon.selectorLabels" . | nindent 6 }}
  28. app.kubernetes.io/component: web
  29. app.kubernetes.io/part-of: rails
  30. template:
  31. metadata:
  32. annotations:
  33. {{- with .Values.podAnnotations }}
  34. {{- toYaml . | nindent 8 }}
  35. {{- end }}
  36. {{- with .Values.mastodon.web.podAnnotations }}
  37. {{- toYaml . | nindent 8 }}
  38. {{- end }}
  39. # roll the pods to pick up any db migrations or other changes
  40. {{- include "mastodon.rollingPodAnnotations" . | nindent 8 }}
  41. labels:
  42. {{- include "mastodon.globalLabels" . | nindent 8 }}
  43. {{- include "mastodon.selectorLabels" . | nindent 8 }}
  44. {{- include "mastodon.statsdExporterLabels" . | nindent 8 }}
  45. {{- with .Values.mastodon.web.podLabels }}
  46. {{- toYaml . | nindent 8 }}
  47. {{- end }}
  48. app.kubernetes.io/component: web
  49. app.kubernetes.io/part-of: rails
  50. spec:
  51. {{- with .Values.imagePullSecrets }}
  52. imagePullSecrets:
  53. {{- toYaml . | nindent 8 }}
  54. {{- end }}
  55. serviceAccountName: {{ include "mastodon.serviceAccountName" . }}
  56. {{- with (default .Values.podSecurityContext .Values.mastodon.web.podSecurityContext) }}
  57. securityContext:
  58. {{- toYaml . | nindent 8 }}
  59. {{- end }}
  60. volumes:
  61. {{- if (not .Values.mastodon.s3.enabled) }}
  62. - name: assets
  63. persistentVolumeClaim:
  64. claimName: {{ template "mastodon.pvc.assets" . }}
  65. - name: system
  66. persistentVolumeClaim:
  67. claimName: {{ template "mastodon.pvc.system" . }}
  68. {{- end }}
  69. {{- include "mastodon.statsdExporterVolume" $ | indent 8 }}
  70. {{- if .Values.mastodon.web.customDatabaseConfigYml.configMapRef.name }}
  71. - name: config-database-yml
  72. configMap:
  73. name: {{ .Values.mastodon.web.customDatabaseConfigYml.configMapRef.name }}
  74. {{- end }}
  75. {{- with .Values.volumes }}
  76. {{- toYaml . | nindent 8 }}
  77. {{- end }}
  78. containers:
  79. - name: {{ .Chart.Name }}-web
  80. {{- with (default .Values.securityContext .Values.mastodon.web.securityContext) }}
  81. securityContext:
  82. {{- toYaml . | nindent 12 }}
  83. {{- end }}
  84. image: "{{ coalesce .Values.mastodon.web.image.repository .Values.image.repository }}:{{ coalesce .Values.mastodon.web.image.tag .Values.image.tag .Chart.AppVersion }}"
  85. imagePullPolicy: {{ .Values.image.pullPolicy }}
  86. command:
  87. - bundle
  88. - exec
  89. - puma
  90. - -C
  91. - config/puma.rb
  92. envFrom:
  93. - configMapRef:
  94. name: {{ include "mastodon.fullname" . }}-env
  95. - secretRef:
  96. name: {{ template "mastodon.secretName" . }}
  97. {{- if .Values.mastodon.extraEnvFrom }}
  98. - configMapRef:
  99. name: {{ .Values.mastodon.extraEnvFrom }}
  100. {{- end}}
  101. env:
  102. - name: "DB_PASS"
  103. valueFrom:
  104. secretKeyRef:
  105. name: {{ template "mastodon.postgresql.secretName" . }}
  106. key: password
  107. {{- if .Values.postgresql.readReplica.auth.existingSecret }}
  108. - name: "REPLICA_DB_PASS"
  109. valueFrom:
  110. secretKeyRef:
  111. name: {{ .Values.postgresql.readReplica.auth.existingSecret}}
  112. key: password
  113. {{- end }}
  114. - name: "REDIS_PASSWORD"
  115. valueFrom:
  116. secretKeyRef:
  117. name: {{ template "mastodon.redis.secretName" . }}
  118. key: redis-password
  119. {{- if and .Values.redis.sidekiq.enabled .Values.redis.sidekiq.auth.existingSecret }}
  120. - name: "SIDEKIQ_REDIS_PASSWORD"
  121. valueFrom:
  122. secretKeyRef:
  123. name: {{ template "mastodon.redis.sidekiq.secretName" . }}
  124. key: redis-password
  125. {{- end }}
  126. {{- if and .Values.redis.cache.enabled .Values.redis.cache.auth.existingSecret }}
  127. - name: "CACHE_REDIS_PASSWORD"
  128. valueFrom:
  129. secretKeyRef:
  130. name: {{ template "mastodon.redis.cache.secretName" . }}
  131. key: redis-password
  132. {{- end }}
  133. {{- if and .Values.elasticsearch.existingSecret (or .Values.elasticsearch.enabled .Values.elasticsearch.hostname) }}
  134. - name: "ES_PASS"
  135. valueFrom:
  136. secretKeyRef:
  137. name: {{ .Values.elasticsearch.existingSecret }}
  138. key: password
  139. {{- end }}
  140. - name: "PORT"
  141. value: {{ .Values.mastodon.web.port | quote }}
  142. {{- if .Values.mastodon.web.minThreads }}
  143. - name: "MIN_THREADS"
  144. value: {{ .Values.mastodon.web.minThreads | quote }}
  145. {{- end }}
  146. {{- if .Values.mastodon.web.maxThreads }}
  147. - name: "MAX_THREADS"
  148. value: {{ .Values.mastodon.web.maxThreads | quote }}
  149. {{- end }}
  150. {{- if .Values.mastodon.web.workers }}
  151. - name: "WEB_CONCURRENCY"
  152. value: {{ .Values.mastodon.web.workers | quote }}
  153. {{- end }}
  154. {{- if .Values.mastodon.web.persistentTimeout }}
  155. - name: "PERSISTENT_TIMEOUT"
  156. value: {{ .Values.mastodon.web.persistentTimeout | quote }}
  157. {{- end }}
  158. {{- if (and .Values.mastodon.s3.enabled .Values.mastodon.s3.existingSecret) }}
  159. - name: "AWS_SECRET_ACCESS_KEY"
  160. valueFrom:
  161. secretKeyRef:
  162. name: {{ .Values.mastodon.s3.existingSecret }}
  163. key: AWS_SECRET_ACCESS_KEY
  164. - name: "AWS_ACCESS_KEY_ID"
  165. valueFrom:
  166. secretKeyRef:
  167. name: {{ .Values.mastodon.s3.existingSecret }}
  168. key: AWS_ACCESS_KEY_ID
  169. {{- end }}
  170. {{- if .Values.mastodon.deepl.enabled }}
  171. - name: "DEEPL_API_KEY"
  172. valueFrom:
  173. secretKeyRef:
  174. name: {{ .Values.mastodon.deepl.apiKeySecretRef.name }}
  175. key: {{ .Values.mastodon.deepl.apiKeySecretRef.key }}
  176. {{- end }}
  177. {{- if .Values.mastodon.hcaptcha.enabled }}
  178. - name: "HCAPTCHA_SECRET_KEY"
  179. valueFrom:
  180. secretKeyRef:
  181. name: {{ .Values.mastodon.hcaptcha.secretKeySecretRef.name }}
  182. key: {{ .Values.mastodon.hcaptcha.secretKeySecretRef.key }}
  183. {{- end }}
  184. {{- if and .Values.mastodon.cacheBuster.enabled .Values.mastodon.cacheBuster.authToken.existingSecret }}
  185. - name: CACHE_BUSTER_SECRET
  186. valueFrom:
  187. secretKeyRef:
  188. name: {{ .Values.mastodon.cacheBuster.authToken.existingSecret }}
  189. key: password
  190. {{- end }}
  191. {{- if or .Values.mastodon.web.otel.enabled (and .Values.mastodon.otel.enabled (ne .Values.mastodon.web.otel.enabled false)) }}
  192. - name: OTEL_EXPORTER_OTLP_ENDPOINT
  193. value: {{ coalesce .Values.mastodon.web.otel.endpointUri .Values.mastodon.otel.endpointUri }}
  194. - name: OTEL_SERVICE_NAME_PREFIX
  195. value: {{ coalesce .Values.mastodon.web.otel.namePrefix .Values.mastodon.otel.namePrefix }}
  196. - name: OTEL_SERVICE_NAME_SEPARATOR
  197. value: "{{ coalesce .Values.mastodon.web.otel.nameSeparator .Values.mastodon.otel.nameSeparator }}"
  198. {{- end }}
  199. volumeMounts:
  200. {{- if (not .Values.mastodon.s3.enabled) }}
  201. - name: assets
  202. mountPath: /opt/mastodon/public/assets
  203. - name: system
  204. mountPath: /opt/mastodon/public/system
  205. {{- end }}
  206. {{- if .Values.mastodon.web.customDatabaseConfigYml.configMapRef.name }}
  207. - name: config-database-yml
  208. mountPath: /opt/mastodon/config/database.yml
  209. subPath: {{ .Values.mastodon.web.customDatabaseConfigYml.configMapRef.key }}
  210. {{- end }}
  211. {{- with .Values.volumeMounts }}
  212. {{- toYaml . | nindent 12 }}
  213. {{- end }}
  214. ports:
  215. - name: http
  216. containerPort: {{ .Values.mastodon.web.port }}
  217. protocol: TCP
  218. livenessProbe:
  219. tcpSocket:
  220. port: http
  221. readinessProbe:
  222. httpGet:
  223. path: /health
  224. port: http
  225. startupProbe:
  226. httpGet:
  227. path: /health
  228. port: http
  229. initialDelaySeconds: 15
  230. failureThreshold: 30
  231. periodSeconds: 5
  232. {{- with (default .Values.resources .Values.mastodon.web.resources) }}
  233. resources:
  234. {{- toYaml . | nindent 12 }}
  235. {{- end }}
  236. {{- include "mastodon.statsdExporterContainer" $ | indent 8 }}
  237. {{- with .Values.nodeSelector }}
  238. nodeSelector:
  239. {{- toYaml . | nindent 8 }}
  240. {{- end }}
  241. {{- with (default .Values.affinity .Values.mastodon.web.affinity) }}
  242. affinity:
  243. {{- toYaml . | nindent 8 }}
  244. {{- end }}
  245. {{- with (default .Values.topologySpreadConstraints .Values.mastodon.web.topologySpreadConstraints) }}
  246. topologySpreadConstraints:
  247. {{- toYaml . | nindent 8 }}
  248. {{- end }}
  249. {{- with (default .Values.tolerations .Values.mastodon.web.tolerations) }}
  250. tolerations:
  251. {{- toYaml . | nindent 8 }}
  252. {{- end }}