Skip to content

Commit 7a5a44e

Browse files
committed
feat(pontoon): add self-host postgres and rabbitmq
the chart now works out of the box, tested with KIND
1 parent eab1e1f commit 7a5a44e

14 files changed

+314
-10
lines changed

charts/pontoon/Chart.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies:
2+
- name: postgresql
3+
repository: https://charts.bitnami.com/bitnami
4+
version: 10.2.0
5+
- name: rabbitmq
6+
repository: https://charts.bitnami.com/bitnami
7+
version: 8.6.0
8+
digest: sha256:acbca669c00cbf636183b351ee7606b260c0f831b7fe4a4a53064f11f62f6795
9+
generated: "2020-12-19T15:28:59.246349-07:00"

charts/pontoon/Chart.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: pontoon
33
home: https://github.com/mozilla/pontoon
4-
version: 1.0.2
4+
version: 1.1.0
55
# Pontoon no longer cuts releases.
66
# See https://github.com/mozilla/pontoon/releases/tag/2018-12-19
77
appVersion: latest
@@ -12,4 +12,15 @@ keywords:
1212
- pontoon
1313
sources:
1414
- https://github.com/mozilla/pontoon
15+
- https://github.com/ibm-skills-network/charts
1516
icon: https://pontoon.mozilla.org/static/img/logo.svg
17+
dependencies:
18+
- name: postgresql
19+
version: 10.2.0
20+
repository: https://charts.bitnami.com/bitnami
21+
condition: postgres.enabled
22+
alias: postgres
23+
- name: rabbitmq
24+
version: 8.6.0
25+
repository: https://charts.bitnami.com/bitnami
26+
condition: rabbitmq.enabled

charts/pontoon/README.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,80 @@
22

33
## Prerequisites
44

5-
- A valid domain name and TLS cert manager
5+
- A valid domain name and TLS certificate (Optional, recommended for production deployment)
6+
- An external managed PostgreSQL and RabbitMQ (Optional, recommended for production deployment)
67
- Kubernetes 1.12+
8+
- Helm 3+
9+
10+
## Chart Details
11+
12+
This chart will do the following
13+
14+
- Deploy Pontoon server(s) and Celery worker deployment(s).
15+
- Deploy a PostgreSQL database and a RabbitMQ instance **NOTE**: For production deployment it is recommended to use external managed services.
16+
17+
## Installing the Chart
18+
19+
### Add skills-network Helm Repository
20+
21+
```bash
22+
helm repo add sn https://charts.skills.network
23+
```
24+
25+
### Install Chart (Non-Production)
26+
27+
If you are looking to try out Pontoon in a non-production environment, such as, [kind](https://kind.sigs.k8s.io/), [minikube](https://minikube.sigs.k8s.io). Save [values-unsafe.yaml](./values-unsafe.yaml) locally.
28+
29+
```bash
30+
helm install pontoon sn/pontoon --values ./values-unsafe.yaml
31+
```
32+
33+
### Install Chart (Production-ish)
34+
35+
This will deploy both Pontoon server and a Celery worker instance, along with both Postgres and RabbitMQ. However, it's still not suitable for production-grade deployment. Save [values-demo.yaml](./values-demo.yaml) locally.
36+
37+
```bash
38+
helm install pontoon sn/pontoon --values ./values-demo.yaml
39+
```
40+
41+
### Install Chart (Production)
42+
43+
Create a value file with the configuration
44+
45+
`values-production.yaml`
46+
47+
```yml
48+
siteUrl: "https://pontoon.example.com"
49+
50+
secretKey: "randomsecret"
51+
52+
extraEnvVars:
53+
- name: ALLOWED_HOSTS
54+
value: "pontoon.example.com"
55+
56+
postgres:
57+
enabled: false
58+
databaseUrl: postgres://username:[email protected]:5432/pontoon
59+
60+
rabbitmq:
61+
enabled: false
62+
url: amqps://username:[email protected]:5672/pontoon
63+
64+
ingress:
65+
enabled: true
66+
annotations:
67+
external-dns.alpha.kubernetes.io/hostname: "pontoon.example.com"
68+
external-dns.alpha.kubernetes.io/target: "ingress.hostname"
69+
cert-manager.io/cluster-issuer: acme-issuer
70+
acme.cert-manager.io/http01-edit-in-place: "true"
71+
hosts:
72+
- "pontoon.example.com"
73+
tls:
74+
- hosts:
75+
- "pontoon.example.com"
76+
secretName: "tls-cert-secret"
77+
```
78+
79+
```bash
80+
helm install pontoon sn/pontoon --values ./values-production.yaml
81+
```

charts/pontoon/templates/NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ kubectl --namespace {{ .Release.Namespace }} exec -ti $POD_NAME -- python manage
2222
{{- else if contains "ClusterIP" .Values.service.type }}
2323
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "component=pontoon" -o jsonpath="{.items[0].metadata.name}")
2424
echo "Visit http://127.0.0.1:8080 to use your application"
25-
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
25+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:8000
2626
{{- end }}

charts/pontoon/templates/_helpers.tpl

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,38 @@ Create the name of the service account to use
6161
{{- end }}
6262
{{- end }}
6363

64+
{{- define "postgres.fullname" -}}
65+
{{- printf "%s-%s" .Release.Name "postgres" | trunc 63 | trimSuffix "-" -}}
66+
{{- end -}}
67+
68+
{{- define "rabbitmq.fullname" -}}
69+
{{- printf "%s-%s" .Release.Name "rabbitmq" | trunc 63 | trimSuffix "-" -}}
70+
{{- end -}}
71+
72+
{{- define "pontoon.database_url" -}}
73+
{{- if .Values.postgres.enabled }}
74+
- name: DATABASE_PASSWORD
75+
valueFrom:
76+
secretKeyRef:
77+
key: postgresql-password
78+
name: {{ include "postgres.fullname" . }}
79+
- name: DATABASE_URL
80+
value: "{{ printf "postgres://%s:$(DATABASE_PASSWORD)@%s/%s" .Values.postgres.postgresqlUsername (include "postgres.fullname" .) .Values.postgres.postgresqlDatabase }}"
81+
{{- end }}
82+
{{- end }}
83+
84+
{{- define "pontoon.rabbitmq_url" -}}
85+
{{- if .Values.postgres.enabled }}
86+
- name: RABBITMQ_PASSWORD
87+
valueFrom:
88+
secretKeyRef:
89+
key: rabbitmq-password
90+
name: {{ include "rabbitmq.fullname" . }}
91+
- name: RABBITMQ_URL
92+
value: "{{ printf "amqp://%s:$(RABBITMQ_PASSWORD)@%s-headless/" .Values.rabbitmq.auth.username (include "rabbitmq.fullname" .) }}"
93+
{{- end }}
94+
{{- end }}
95+
6496
{{/* vim: set filetype=mustache: */}}
6597
{{/*
6698
Renders a value that contains template.
@@ -73,4 +105,4 @@ Usage:
73105
{{- else }}
74106
{{- tpl (.value | toYaml) .context }}
75107
{{- end }}
76-
{{- end -}}
108+
{{- end -}}

charts/pontoon/templates/pontoon-deployment.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ spec:
2424
checksum/pontoon-secrets: {{ include (print $.Template.BasePath "/pontoon-secrets.yaml") . | sha256sum }}
2525
checksum/pontoon-ssh-secrets: {{ include (print $.Template.BasePath "/pontoon-ssh-secrets.yaml") . | sha256sum }}
2626
checksum/pontoon-settings: {{ include (print $.Template.BasePath "/pontoon-settings-configmap.yaml") . | sha256sum }}
27+
checksum/pontoon-unsafe-wsgi: {{ include (print $.Template.BasePath "/pontoon-unsafe-wsgi-configmap.yaml") . | sha256sum }}
2728
{{- range $key, $value := .Values.podAnnotations }}
2829
{{ $key }}: {{ $value | quote }}
2930
{{- end }}
@@ -89,6 +90,8 @@ spec:
8990
{{- if .Values.extraEnvVars }}
9091
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
9192
{{- end }}
93+
{{- include "pontoon.database_url" . | indent 12 }}
94+
{{- include "pontoon.rabbitmq_url" . | indent 12 }}
9295
volumeMounts:
9396
{{- if .Values.extraSettingsModule }}
9497
- mountPath: "{{ .Values.pontoonHome }}/pontoon/settings/custom.py"
@@ -99,6 +102,11 @@ spec:
99102
- name: "dummy-volume"
100103
mountPath: {{ .Values.ssh.mountPath | quote }}
101104
{{- end }}
105+
{{- if not .Values.forceSsl }}
106+
- mountPath: "{{ .Values.pontoonHome }}/pontoon/wsgi.py"
107+
name: "pontoon-wsgi"
108+
subPath: "wsgi.py"
109+
{{- end }}
102110
volumes:
103111
{{- if .Values.extraSettingsModule }}
104112
- name: "pontoon-settings"
@@ -113,6 +121,11 @@ spec:
113121
- name: "dummy-volume"
114122
emptyDir: {}
115123
{{- end }}
124+
{{- if not .Values.forceSsl }}
125+
- name: "pontoon-wsgi"
126+
configMap:
127+
name: "{{ include "pontoon.fullname" . }}-unsafe-wsgi-configmap"
128+
{{- end }}
116129
{{- with .Values.nodeSelector }}
117130
nodeSelector:
118131
{{- toYaml . | nindent 8 }}

charts/pontoon/templates/pontoon-migration-job.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ spec:
4949
{{- if .Values.extraEnvVars }}
5050
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
5151
{{- end }}
52+
{{- include "pontoon.database_url" . | indent 12 }}
53+
{{- include "pontoon.rabbitmq_url" . | indent 12 }}
5254
volumeMounts:
5355
{{- if .Values.extraSettingsModule }}
5456
- mountPath: "{{ .Values.pontoonHome }}/pontoon/settings/custom.py"

charts/pontoon/templates/pontoon-secrets.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ metadata:
55
type: Opaque
66
data:
77
SECRET_KEY: {{ .Values.secretKey | b64enc | quote }}
8+
{{- if not .Values.postgres.enabled }}
89
DATABASE_URL: {{ .Values.postgres.databaseUrl | b64enc | quote }}
10+
{{- end }}
11+
{{- if not .Values.rabbitmq.enabled }}
912
RABBITMQ_URL: {{ .Values.rabbitmq.url | b64enc | quote }}
13+
{{- end }}

charts/pontoon/templates/pontoon-sync-projects-cronjob.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ spec:
7373
{{- if .Values.extraEnvVars }}
7474
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 16 }}
7575
{{- end }}
76+
{{- include "pontoon.database_url" . | indent 16 }}
77+
{{- include "pontoon.rabbitmq_url" . | indent 16 }}
7678
volumeMounts:
7779
{{- if .Values.extraSettingsModule }}
7880
- mountPath: "{{ .Values.pontoonHome }}/pontoon/settings/custom.py"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{ if not .Values.forceSsl }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: "{{ include "pontoon.fullname" . }}-unsafe-wsgi-configmap"
6+
labels:
7+
app: {{ include "pontoon.fullname" . }}
8+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
9+
heritage: {{ .Release.Service }}
10+
release: {{ .Release.Name }}
11+
data:
12+
# This file is taken from https://github.com/mozilla/pontoon/blob/master/pontoon/wsgi.py
13+
# and remove `wsgi_sslify` in order to make it works without a valid TLS certificate
14+
wsgi.py: |-
15+
"""
16+
WSGI config for Pontoon.
17+
It exposes the WSGI callable as a module-level variable named ``application``.
18+
For more information on this file, see
19+
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
20+
"""
21+
import os
22+
23+
import dotenv
24+
from django.core.wsgi import get_wsgi_application
25+
from wsgi_sslify import sslify
26+
27+
28+
if "DOTENV_PATH" in os.environ:
29+
dotenv.read_dotenv(os.environ["DOTENV_PATH"])
30+
31+
# Set settings env var before importing whitenoise as it depends on
32+
# some settings.
33+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pontoon.settings")
34+
35+
# sslify sets a Strict-Transport-Security header,
36+
# which instructs browsers to always use HTTPS.
37+
application = get_wsgi_application()
38+
{{- end }}

0 commit comments

Comments
 (0)