Skip to content

Commit ec0246d

Browse files
authored
Merge pull request #149 from small-hack/merge-main-kinda
merged all the important stuff from upstream
2 parents 0e6e82e + 2ccfe94 commit ec0246d

21 files changed

+1170
-157
lines changed

charts/mastodon/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type: application
99
# This is the chart version. This version number should be incremented each time you make changes
1010
# to the chart and its templates, including the app version.
1111
# Versions are expected to follow Semantic Versioning (https://semver.org/)
12-
version: 10.1.3
12+
version: 11.0.0
1313

1414
# renovate: image=ghcr.io/mastodon/mastodon
1515
appVersion: v4.4.4

charts/mastodon/README.md

Lines changed: 92 additions & 10 deletions
Large diffs are not rendered by default.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Spec template for DB migration pre- and post-install/upgrade jobs.
4+
*/}}
5+
{{- define "mastodon.dbMigrateJob" -}}
6+
apiVersion: batch/v1
7+
kind: Job
8+
metadata:
9+
{{- if .prepare }}
10+
name: {{ include "mastodon.fullname" . }}-db-prepare
11+
{{- else if .preDeploy }}
12+
name: {{ include "mastodon.fullname" . }}-db-pre-migrate
13+
{{- else }}
14+
name: {{ include "mastodon.fullname" . }}-db-post-migrate
15+
{{- end }}
16+
labels:
17+
{{- include "mastodon.labels" . | nindent 4 }}
18+
annotations:
19+
{{- if .prepare }}
20+
"helm.sh/hook": pre-install
21+
{{- else if .preDeploy }}
22+
"helm.sh/hook": pre-upgrade
23+
{{- else }}
24+
"helm.sh/hook": post-install,post-upgrade
25+
{{- end }}
26+
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
27+
{{- if .prepare }}
28+
"helm.sh/hook-weight": "-3"
29+
{{- else }}
30+
"helm.sh/hook-weight": "-2"
31+
{{- end }}
32+
spec:
33+
template:
34+
metadata:
35+
name: {{ include "mastodon.fullname" . }}-db-migrate
36+
{{- with .Values.jobAnnotations }}
37+
annotations:
38+
{{- toYaml . | nindent 8 }}
39+
{{- end }}
40+
spec:
41+
restartPolicy: Never
42+
containers:
43+
- name: {{ include "mastodon.fullname" . }}-db-migrate
44+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
45+
imagePullPolicy: {{ .Values.image.pullPolicy }}
46+
command:
47+
- bundle
48+
- exec
49+
- rake
50+
{{- if .prepare }}
51+
- db:prepare
52+
{{- else }}
53+
- db:migrate
54+
{{- end }}
55+
envFrom:
56+
- secretRef:
57+
{{- if and .prepare (not .Values.mastodon.secrets.existingSecret) }}
58+
name: {{ template "mastodon.secretName" . }}-prepare
59+
{{- else }}
60+
name: {{ template "mastodon.secretName" . }}
61+
{{- end }}
62+
env:
63+
- name: "DB_HOST"
64+
value: {{ template "mastodon.postgres.direct.host" . }}
65+
- name: "DB_PORT"
66+
value: {{ template "mastodon.postgres.direct.port" . }}
67+
- name: "DB_NAME"
68+
value: {{ template "mastodon.postgres.direct.database" . }}
69+
- name: "DB_USER"
70+
value: {{ .Values.postgresql.auth.username }}
71+
- name: "DB_PASS"
72+
valueFrom:
73+
secretKeyRef:
74+
name: {{ template "mastodon.postgresql.secretName" . }}
75+
key: password
76+
- name: "REDIS_HOST"
77+
value: {{ template "mastodon.redis.host" . }}
78+
- name: "REDIS_PORT"
79+
value: {{ .Values.redis.port | default "6379" | quote }}
80+
{{- if .Values.redis.sidekiq.enabled }}
81+
{{- if .Values.redis.sidekiq.hostname }}
82+
- name: SIDEKIQ_REDIS_HOST
83+
value: {{ .Values.redis.sidekiq.hostname }}
84+
{{- end }}
85+
{{- if .Values.redis.sidekiq.port }}
86+
- name: SIDEKIQ_REDIS_PORT
87+
value: {{ .Values.redis.sidekiq.port | quote }}
88+
{{- end }}
89+
{{- end }}
90+
{{- if .Values.redis.cache.enabled }}
91+
{{- if .Values.redis.cache.hostname }}
92+
- name: CACHE_REDIS_HOST
93+
value: {{ .Values.redis.cache.hostname }}
94+
{{- end }}
95+
{{- if .Values.redis.cache.port }}
96+
- name: CACHE_REDIS_PORT
97+
value: {{ .Values.redis.cache.port | quote }}
98+
{{- end }}
99+
{{- end }}
100+
- name: "REDIS_DRIVER"
101+
value: "ruby"
102+
- name: "REDIS_PASSWORD"
103+
valueFrom:
104+
secretKeyRef:
105+
{{- if and (.prepare) (not .Values.redis.enabled) (not .Values.redis.auth.existingSecret) (not .Values.redis.existingSecret) (.Values.redis.auth.password) }}
106+
name: {{ template "mastodon.redis.secretName" . }}-pre-install
107+
{{- else }}
108+
name: {{ template "mastodon.redis.secretName" . }}
109+
{{- end }}
110+
key: redis-password
111+
{{- if .preDeploy }}
112+
- name: "SKIP_POST_DEPLOYMENT_MIGRATIONS"
113+
value: "true"
114+
{{- end }}
115+
{{- end }}

charts/mastodon/templates/_helpers.tpl

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ Create chart name and version as used by the chart label.
3030
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
3131
{{- end }}
3232

33+
34+
{{/*
35+
Labels added on every Mastodon resource
36+
*/}}
37+
{{- define "mastodon.globalLabels" -}}
38+
{{- range $k, $v := .Values.mastodon.labels }}
39+
{{ $k }}: {{ quote $v }}
40+
{{- end -}}
41+
{{- end }}
42+
3343
{{/*
3444
Common labels
3545
*/}}
@@ -110,6 +120,60 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
110120
{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}}
111121
{{- end -}}
112122

123+
{{/*
124+
Establish which values we will use for remote connections
125+
*/}}
126+
{{- define "mastodon.postgres.host" -}}
127+
{{- if .Values.postgresql.enabled }}
128+
{{- printf "%s" (include "mastodon.postgresql.fullname" .) -}}
129+
{{- else }}
130+
{{- printf "%s" (required "When the postgresql chart is disabled .Values.postgresql.postgresqlHostname is required" .Values.postgresql.postgresqlHostname) -}}
131+
{{- end }}
132+
{{- end }}
133+
134+
{{- define "mastodon.postgres.port" -}}
135+
{{- if .Values.postgresql.enabled }}
136+
{{- printf "%d" 5432 | int | quote -}}
137+
{{- else }}
138+
{{- printf "%d" | default 5432 .Values.postgresql.postgresqlPort | int | quote -}}
139+
{{- end }}
140+
{{- end }}
141+
142+
{{/*
143+
Establish which values we will use for direct remote DB connections
144+
*/}}
145+
{{- define "mastodon.postgres.direct.host" -}}
146+
{{- if .Values.postgresql.direct.hostname }}
147+
{{- printf "%s" .Values.postgresql.direct.hostname -}}
148+
{{- else }}
149+
{{- printf "%s" (include "mastodon.postgres.host" .) -}}
150+
{{- end }}
151+
{{- end }}
152+
153+
{{- define "mastodon.postgres.direct.port" -}}
154+
{{- if .Values.postgresql.direct.port }}
155+
{{- printf "%d" (int .Values.postgresql.direct.port) | quote -}}
156+
{{- else }}
157+
{{- printf "%s" (include "mastodon.postgres.port" .) -}}
158+
{{- end }}
159+
{{- end }}
160+
161+
{{- define "mastodon.postgres.direct.database" -}}
162+
{{- if .Values.postgresql.direct.database }}
163+
{{- printf "%s" .Values.postgresql.direct.database -}}
164+
{{- else }}
165+
{{- printf "%s" .Values.postgresql.auth.database -}}
166+
{{- end }}
167+
{{- end }}
168+
169+
{{- define "mastodon.redis.host" -}}
170+
{{- if .Values.redis.enabled }}
171+
{{- printf "%s-%s" (include "mastodon.redis.fullname" .) "master" -}}
172+
{{- else }}
173+
{{- printf "%s" (required "When the redis chart is disabled .Values.redis.hostname is required" .Values.redis.hostname) -}}
174+
{{- end }}
175+
{{- end }}
176+
113177
{{/*
114178
Get the mastodon secret.
115179
*/}}
@@ -132,6 +196,15 @@ Get the smtp secret.
132196
{{- end -}}
133197
{{- end -}}
134198

199+
200+
{{- define "mastodon.smtp.bulk.secretName" -}}
201+
{{- if .Values.mastodon.smtp.bulk.existingSecret }}
202+
{{- printf "%s" (tpl .Values.mastodon.smtp.bulk.existingSecret $) -}}
203+
{{- else -}}
204+
{{- printf "%s-smtp-bulk" (include "mastodon.fullname" .) -}}
205+
{{- end -}}
206+
{{- end -}}
207+
135208
{{/*
136209
Get the postgresql secret.
137210
*/}}
@@ -214,3 +287,16 @@ Find highest number of needed database connections to set DB_POOL variable
214287
{{- end }}
215288
{{- $poolSize | quote }}
216289
{{- end }}
290+
291+
{{/*
292+
Full hostname for a custom Elasticsearch cluster
293+
*/}}
294+
{{- define "mastodon.elasticsearch.fullHostname" -}}
295+
{{- if not .Values.elasticsearch.enabled }}
296+
{{- if .Values.elasticsearch.tls }}
297+
{{- printf "https://%s" (tpl .Values.elasticsearch.hostname $) -}}
298+
{{- else -}}
299+
{{- printf "%s" (tpl .Values.elasticsearch.hostname $) -}}
300+
{{- end }}
301+
{{- end -}}
302+
{{- end -}}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Spec template for mastodon secrets object.
4+
*/}}
5+
{{- define "mastodon.secrets.object" -}}
6+
apiVersion: v1
7+
kind: Secret
8+
metadata:
9+
{{- if .prepare }}
10+
name: {{ template "mastodon.fullname" . }}-prepare
11+
{{- else }}
12+
name: {{ template "mastodon.fullname" . }}
13+
{{- end }}
14+
labels:
15+
{{- include "mastodon.labels" . | nindent 4 }}
16+
annotations:
17+
{{- if .prepare }}
18+
"helm.sh/hook": pre-install
19+
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
20+
"helm.sh/hook-weight": "-3"
21+
{{- end }}
22+
type: Opaque
23+
data:
24+
{{- if .Values.mastodon.s3.enabled }}
25+
{{- if not .Values.mastodon.s3.existingSecret }}
26+
AWS_ACCESS_KEY_ID: "{{ .Values.mastodon.s3.access_key | b64enc }}"
27+
AWS_SECRET_ACCESS_KEY: "{{ .Values.mastodon.s3.access_secret | b64enc }}"
28+
{{- end }}
29+
{{- end }}
30+
{{- if not .Values.mastodon.secrets.existingSecret }}
31+
{{- if not (empty .Values.mastodon.secrets.secret_key_base) }}
32+
SECRET_KEY_BASE: "{{ .Values.mastodon.secrets.secret_key_base | b64enc }}"
33+
{{- else }}
34+
SECRET_KEY_BASE: {{ required "secret_key_base is required" .Values.mastodon.secrets.secret_key_base }}
35+
{{- end }}
36+
{{- if not (empty .Values.mastodon.secrets.otp_secret) }}
37+
OTP_SECRET: "{{ .Values.mastodon.secrets.otp_secret | b64enc }}"
38+
{{- else }}
39+
OTP_SECRET: {{ required "otp_secret is required" .Values.mastodon.secrets.otp_secret }}
40+
{{- end }}
41+
{{- if not (empty .Values.mastodon.secrets.vapid.private_key) }}
42+
VAPID_PRIVATE_KEY: "{{ .Values.mastodon.secrets.vapid.private_key | b64enc }}"
43+
{{- else }}
44+
VAPID_PRIVATE_KEY: {{ required "vapid.private_key is required" .Values.mastodon.secrets.vapid.private_key }}
45+
{{- end }}
46+
{{- if not (empty .Values.mastodon.secrets.vapid.public_key) }}
47+
VAPID_PUBLIC_KEY: "{{ .Values.mastodon.secrets.vapid.public_key | b64enc }}"
48+
{{- else }}
49+
VAPID_PUBLIC_KEY: {{ required "vapid.public_key is required" .Values.mastodon.secrets.vapid.public_key }}
50+
{{- end }}
51+
{{- if not (empty .Values.mastodon.secrets.activeRecordEncryption.primaryKey) }}
52+
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: "{{ .Values.mastodon.secrets.activeRecordEncryption.primaryKey | b64enc }}"
53+
{{- else }}
54+
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: {{ required "activeRecordEncryption.primaryKey is required" .Values.mastodon.secrets.activeRecordEncryption.primaryKey }}
55+
{{- end }}
56+
{{- if not (empty .Values.mastodon.secrets.activeRecordEncryption.deterministicKey) }}
57+
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: "{{ .Values.mastodon.secrets.activeRecordEncryption.deterministicKey | b64enc }}"
58+
{{- else }}
59+
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: {{ required "activeRecordEncryption.deterministicKey is required" .Values.mastodon.secrets.activeRecordEncryption.deterministicKey }}
60+
{{- end }}
61+
{{- if not (empty .Values.mastodon.secrets.activeRecordEncryption.keyDerivationSalt) }}
62+
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: "{{ .Values.mastodon.secrets.activeRecordEncryption.keyDerivationSalt | b64enc }}"
63+
{{- else }}
64+
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: {{ required "activeRecordEncryption.keyDerivationSalt is required" .Values.mastodon.secrets.activeRecordEncryption.keyDerivationSalt }}
65+
{{- end }}
66+
{{- end }}
67+
{{- if not .Values.postgresql.enabled }}
68+
{{- if not .Values.postgresql.auth.existingSecret }}
69+
password: "{{ .Values.postgresql.auth.password | b64enc }}"
70+
{{- end }}
71+
{{- end }}
72+
{{- end }}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{{/*
2+
The exporter container attached to every Mastodon pod
3+
*/}}
4+
5+
{{- define "mastodon.statsdExporterContainer" }}
6+
{{- with .Values.mastodon.metrics.statsd }}
7+
{{- if and .exporter.enabled (not .address) }}
8+
- name: statsd-exporter
9+
image: prom/statsd-exporter
10+
args:
11+
- "--statsd.mapping-config=/statsd-mappings/mastodon.yml"
12+
resources:
13+
requests:
14+
cpu: "0.1"
15+
memory: "180M"
16+
limits:
17+
cpu: "0.5"
18+
memory: "250M"
19+
ports:
20+
- name: statsd
21+
containerPort: {{ .exporter.port }}
22+
volumeMounts:
23+
- name: statsd-mappings
24+
mountPath: /statsd-mappings
25+
{{- end }}
26+
{{- end }}
27+
{{- end }}
28+
29+
{{/*
30+
The volume needed for the container above
31+
*/}}
32+
{{- define "mastodon.statsdExporterVolume" }}
33+
{{- with .Values.mastodon.metrics.statsd }}
34+
{{- if and .exporter.enabled (not .address) }}
35+
- name: statsd-mappings
36+
configMap:
37+
name: {{ include "mastodon.fullname" $ }}-statsd-mappings
38+
items:
39+
- key: mastodon-statsd-mappings.yml
40+
path: mastodon.yml
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}
44+
45+
{{/*
46+
Labels added to every statsd_exporter-enabled pod
47+
*/}}
48+
{{- define "mastodon.statsdExporterLabels" }}
49+
{{- with .Values.mastodon.metrics.statsd }}
50+
{{- if and .exporter.enabled (not .address) }}
51+
mastodon/statsd-exporter: "true"
52+
{{- end }}
53+
{{- end }}
54+
{{- end }}

0 commit comments

Comments
 (0)