forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Helm chart known issues/future work: - SSO is unsupported - S3/Minio/GCS is unsupported - Swift is unsupported - WEB_DOMAIN is unsupported - Tor is unsupported * helm: clarify how LOCAL_DOMAIN is set * helm: add chart description * helm: make DB_POOL and Sidekiq concurrency configurable * helm: only enforce pod affinity when using ReadWriteOnce * helm: clarify compatibility * helm: clean up application variables * helm: add job to create initial admin
- Loading branch information
Showing
24 changed files
with
1,178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apiVersion: v2 | ||
name: mastodon | ||
description: Mastodon is a free, open-source social network server based on ActivityPub. | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.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: 3.1.4 | ||
|
||
dependencies: | ||
- name: elasticsearch | ||
version: "12.x.x" | ||
repository: https://charts.bitnami.com/bitnami | ||
condition: elasticsearch.enabled | ||
- name: postgresql | ||
version: "8.x.x" | ||
repository: https://charts.bitnami.com/bitnami | ||
- name: redis | ||
version: "10.x.x" | ||
repository: https://charts.bitnami.com/bitnami |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Introduction | ||
|
||
This is a [Helm](https://helm.sh/) chart for installing Mastodon into a | ||
Kubernetes cluster. The basic usage is: | ||
|
||
``` | ||
cp values.yaml.template values.yaml | ||
edit values.yaml # configure required settings | ||
helm dep update | ||
helm upgrade --install my-mastodon ./ | ||
``` | ||
|
||
This chart has been tested on Helm 3.0.1 and above. | ||
|
||
# Configuration | ||
|
||
The variables that _must_ be configured are: | ||
|
||
- `ingress.hostname`; even if you aren’t using an Ingress, this value is used to | ||
set `LOCAL_DOMAIN`. | ||
|
||
- password and keys in the `secrets`, `postgresql`, and `redis` groups; if | ||
left blank, some of those values will be autogenerated, but will not persist | ||
across upgrades. | ||
|
||
- SMTP settings for your mailer in the `smtp` group. | ||
|
||
# Missing features | ||
|
||
Currently this chart does _not_ support: | ||
|
||
- Hidden services | ||
- S3/Minio/GCS | ||
- Single Sign-On | ||
- Swift | ||
- configurations using `WEB_DOMAIN` | ||
|
||
# Upgrading | ||
|
||
Because database migrations are managed as a Job separate from the Rails and | ||
Sidekiq deployments, it’s possible they will occur in the wrong order. After | ||
upgrading Mastodon versions, it may sometimes be necessary to manually delete | ||
the Rails and Sidekiq pods so that they are recreated against the latest | ||
migration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
1. Get the application URL by running these commands: | ||
{{- if .Values.ingress.enabled }} | ||
{{- range $host := .Values.ingress.hosts }} | ||
{{- range .paths }} | ||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- else if contains "NodePort" .Values.service.type }} | ||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mastodon.fullname" . }}) | ||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") | ||
echo http://$NODE_IP:$NODE_PORT | ||
{{- else if contains "LoadBalancer" .Values.service.type }} | ||
NOTE: It may take a few minutes for the LoadBalancer IP to be available. | ||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mastodon.fullname" . }}' | ||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mastodon.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") | ||
echo http://$SERVICE_IP:{{ .Values.service.port }} | ||
{{- else if contains "ClusterIP" .Values.service.type }} | ||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mastodon.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") | ||
echo "Visit http://127.0.0.1:8080 to use your application" | ||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "mastodon.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "mastodon.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "mastodon.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "mastodon.labels" -}} | ||
helm.sh/chart: {{ include "mastodon.chart" . }} | ||
{{ include "mastodon.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "mastodon.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "mastodon.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "mastodon.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "mastodon.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified name for dependent services. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
*/}} | ||
{{- define "mastodon.elasticsearch.fullname" -}} | ||
{{- printf "%s-%s" .Release.Name "elasticsearch" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{- define "mastodon.redis.fullname" -}} | ||
{{- printf "%s-%s" .Release.Name "redis" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{- define "mastodon.postgresql.fullname" -}} | ||
{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "mastodon.fullname" . }}-env | ||
labels: | ||
{{- include "mastodon.labels" . | nindent 4 }} | ||
data: | ||
DB_HOST: {{ template "mastodon.postgresql.fullname" . }} | ||
DB_NAME: {{ .Values.postgresql.postgresqlDatabase }} | ||
DB_POOL: {{ .Values.application.sidekiq.concurrency | quote }} | ||
DB_PORT: "5432" | ||
DB_USER: {{ .Values.postgresql.postgresqlUsername }} | ||
DEFAULT_LOCALE: {{ .Values.locale }} | ||
{{- if .Values.elasticsearch.enabled }} | ||
ES_ENABLED: "true" | ||
ES_HOST: {{ template "mastodon.elasticsearch.fullname" . }}-master | ||
ES_PORT: "9200" | ||
{{- end }} | ||
LOCAL_DOMAIN: {{ .Values.ingress.hostname }} | ||
# https://devcenter.heroku.com/articles/tuning-glibc-memory-behavior | ||
MALLOC_ARENA_MAX: "2" | ||
NODE_ENV: "production" | ||
RAILS_ENV: "production" | ||
REDIS_HOST: {{ template "mastodon.redis.fullname" . }}-master | ||
REDIS_PORT: "6379" | ||
{{- if .Values.smtp.auth_method }} | ||
SMTP_AUTH_METHOD: {{ .Values.smtp.auth_method }} | ||
{{- end }} | ||
{{- if .Values.smtp.ca_file }} | ||
SMTP_CA_FILE: {{ .Values.smtp.ca_file }} | ||
{{- end }} | ||
{{- if .Values.smtp.delivery_method }} | ||
SMTP_DELIVERY_METHOD: {{ .Values.smtp.delivery_method }} | ||
{{- end }} | ||
{{- if .Values.smtp.domain }} | ||
SMTP_DOMAIN: {{ .Values.smtp.domain }} | ||
{{- end }} | ||
{{- if .Values.smtp.enable_starttls_auto }} | ||
SMTP_ENABLE_STARTTLS_AUTO: {{ .Values.smtp.enable_starttls_auto | quote }} | ||
{{- end }} | ||
{{- if .Values.smtp.from_address }} | ||
SMTP_FROM_ADDRESS: {{ .Values.smtp.from_address }} | ||
{{- end }} | ||
{{- if .Values.smtp.login }} | ||
SMTP_LOGIN: {{ .Values.smtp.login }} | ||
{{- end }} | ||
{{- if .Values.smtp.openssl_verify_mode }} | ||
SMTP_OPENSSL_VERIFY_MODE: {{ .Values.smtp.openssl_verify_mode }} | ||
{{- end }} | ||
{{- if .Values.smtp.password }} | ||
SMTP_PASSWORD: {{ .Values.smtp.password }} | ||
{{- end }} | ||
{{- if .Values.smtp.port }} | ||
SMTP_PORT: {{ .Values.smtp.port | quote }} | ||
{{- end }} | ||
{{- if .Values.smtp.reply_to }} | ||
SMTP_REPLY_TO: {{ .Values.smtp.reply_to }} | ||
{{- end }} | ||
{{- if .Values.smtp.server }} | ||
SMTP_SERVER: {{ .Values.smtp.server }} | ||
{{- end }} | ||
{{- if .Values.smtp.tls }} | ||
SMTP_TLS: {{ .Values.smtp.tls | quote }} | ||
{{- end }} | ||
STREAMING_CLUSTER_NUM: {{ .Values.application.streaming.workers | quote }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "mastodon.fullname" . }}-sidekiq | ||
labels: | ||
{{- include "mastodon.labels" . | nindent 4 }} | ||
spec: | ||
{{- if not .Values.autoscaling.enabled }} | ||
replicas: {{ .Values.replicaCount }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
{{- include "mastodon.selectorLabels" . | nindent 6 }} | ||
component: rails | ||
template: | ||
metadata: | ||
{{- with .Values.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
# roll the pods to pick up any db migrations | ||
rollme: {{ randAlphaNum 5 | quote }} | ||
{{- end }} | ||
labels: | ||
{{- include "mastodon.selectorLabels" . | nindent 8 }} | ||
component: rails | ||
spec: | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "mastodon.serviceAccountName" . }} | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
# 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.persistence.assets.accessMode) (eq "ReadWriteOnce" .Values.persistence.system.accessMode) }} | ||
affinity: | ||
podAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: component | ||
operator: In | ||
values: | ||
- rails | ||
topologyKey: kubernetes.io/hostname | ||
{{- end }} | ||
volumes: | ||
- name: assets | ||
persistentVolumeClaim: | ||
claimName: {{ template "mastodon.fullname" . }}-assets | ||
- name: system | ||
persistentVolumeClaim: | ||
claimName: {{ template "mastodon.fullname" . }}-system | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
command: | ||
- bundle | ||
- exec | ||
- sidekiq | ||
- -c | ||
- {{ .Values.application.sidekiq.concurrency | quote }} | ||
envFrom: | ||
- configMapRef: | ||
name: {{ include "mastodon.fullname" . }}-env | ||
- secretRef: | ||
name: {{ template "mastodon.fullname" . }} | ||
env: | ||
- name: "DB_PASS" | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Release.Name }}-postgresql | ||
key: postgresql-password | ||
- name: "REDIS_PASSWORD" | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Release.Name }}-redis | ||
key: redis-password | ||
volumeMounts: | ||
- name: assets | ||
mountPath: /opt/mastodon/public/assets | ||
- name: system | ||
mountPath: /opt/mastodon/public/system | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
{{- with .Values.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
Oops, something went wrong.