Skip to content

Commit 0c9f968

Browse files
committed
chore(pontoon): add chart
0 parents  commit 0c9f968

19 files changed

+893
-0
lines changed

.github/workflows/helm-release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Helm Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Configure Git
18+
run: |
19+
git config user.name "$GITHUB_ACTOR"
20+
git config user.email "[email protected]"
21+
22+
- name: Install Helm
23+
uses: azure/setup-helm@v1
24+
with:
25+
version: v3.4.0
26+
27+
- name: Run chart-releaser
28+
uses: helm/[email protected]
29+
env:
30+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

charts/pontoon/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/pontoon/Chart.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v2
2+
name: pontoon
3+
home: https://github.com/mozilla/pontoon
4+
version: 1.0.0
5+
# Pontoon no longer cuts releases.
6+
# See https://github.com/mozilla/pontoon/releases/tag/2018-12-19
7+
appVersion: latest
8+
type: application
9+
description: A Helm chart for Pontoon, a Mozilla's Localization Platform.
10+
keywords:
11+
- i18n
12+
- pontoon
13+
sources:
14+
- https://github.com/mozilla/pontoon
15+
icon: https://pontoon.mozilla.org/static/img/logo.svg

charts/pontoon/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Pontoon Helm Chart
2+
3+
## Prerequisites
4+
5+
- A valid domain name and TLS cert manager
6+
- Kubernetes 1.12+

charts/pontoon/templates/NOTES.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Congratulations. You have just deployed Pontoon!
2+
3+
1. Create an admin account
4+
5+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "component=pontoon" -o jsonpath="{.items[0].metadata.name}")
6+
kubectl --namespace {{ .Release.Namespace }} exec -ti $POD_NAME -- python manage.py createsuperuser
7+
8+
2. Get the application URL by running these commands:
9+
{{- if .Values.ingress.enabled }}
10+
{{- range $host := .Values.ingress.hosts }}
11+
https://{{ $host }}
12+
{{- end }}
13+
{{- else if contains "NodePort" .Values.service.type }}
14+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "pontoon.fullname" . }})
15+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
16+
echo http://$NODE_IP:$NODE_PORT
17+
{{- else if contains "LoadBalancer" .Values.service.type }}
18+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
19+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "pontoon.fullname" . }}'
20+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "pontoon.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
21+
echo http://$SERVICE_IP:{{ .Values.service.port }}
22+
{{- else if contains "ClusterIP" .Values.service.type }}
23+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "component=pontoon" -o jsonpath="{.items[0].metadata.name}")
24+
echo "Visit http://127.0.0.1:8080 to use your application"
25+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
26+
{{- end }}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "pontoon.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "pontoon.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "pontoon.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "pontoon.labels" -}}
37+
helm.sh/chart: {{ include "pontoon.chart" . }}
38+
{{ include "pontoon.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "pontoon.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "pontoon.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "pontoon.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "pontoon.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/* vim: set filetype=mustache: */}}
65+
{{/*
66+
Renders a value that contains template.
67+
Usage:
68+
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
69+
*/}}
70+
{{- define "common.tplvalues.render" -}}
71+
{{- if typeIs "string" .value }}
72+
{{- tpl .value .context }}
73+
{{- else }}
74+
{{- tpl (.value | toYaml) .context }}
75+
{{- end }}
76+
{{- end -}}

charts/pontoon/templates/hpa.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2beta1
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "pontoon.fullname" . }}
6+
labels:
7+
{{- include "pontoon.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "pontoon.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
21+
{{- end }}
22+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
23+
- type: Resource
24+
resource:
25+
name: memory
26+
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
27+
{{- end }}
28+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Loop through the imagePullSecrets to create image pull secrets
2+
{{- range .Values.imagePullSecrets }}
3+
{{- if and .name .create }}
4+
---
5+
apiVersion: v1
6+
kind: Secret
7+
type: kubernetes.io/dockerconfigjson
8+
metadata:
9+
name: {{ .name | quote }}
10+
data:
11+
.dockerconfigjson: {{ printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .url (printf "%s:%s" .username .password | b64enc) | b64enc }}
12+
{{- end }}
13+
{{- end }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $serviceName := include "pontoon.fullname" . -}}
3+
{{- $servicePort := .Values.service.externalPort -}}
4+
{{- $ingressName := default ( include "pontoon.fullname" . ) .Values.ingress.name -}}
5+
{{- if semverCompare ">=v1.14.0-0" .Capabilities.KubeVersion.GitVersion }}
6+
apiVersion: networking.k8s.io/v1beta1
7+
{{- else }}
8+
apiVersion: extensions/v1beta1
9+
{{- end }}
10+
kind: Ingress
11+
metadata:
12+
name: {{ $ingressName }}
13+
labels:
14+
app: {{ include "pontoon.fullname" . }}
15+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
16+
heritage: {{ .Release.Service }}
17+
release: {{ .Release.Name }}
18+
{{- if .Values.ingress.labels }}
19+
{{ .Values.ingress.labels | toYaml | trimSuffix "\n"| indent 4 -}}
20+
{{- end}}
21+
{{- if .Values.ingress.annotations }}
22+
annotations:
23+
{{ .Values.ingress.annotations | toYaml | trimSuffix "\n" | indent 4 -}}
24+
{{- end }}
25+
spec:
26+
{{- if .Values.ingress.tls }}
27+
tls:
28+
{{- toYaml .Values.ingress.tls | nindent 4 }}
29+
{{- end }}
30+
rules:
31+
{{- if .Values.ingress.hosts }}
32+
{{- range $host := .Values.ingress.hosts }}
33+
- host: {{ $host | quote }}
34+
http:
35+
paths:
36+
- path: {{ $.Values.ingress.routerPath }}
37+
backend:
38+
serviceName: {{ $serviceName }}
39+
servicePort: {{ $servicePort }}
40+
{{- end -}}
41+
{{- end -}}
42+
{{- end -}}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "pontoon.fullname" . }}
5+
labels:
6+
app: {{ include "pontoon.fullname" . }}
7+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
8+
heritage: {{ .Release.Service }}
9+
release: {{ .Release.Name }}
10+
component: "pontoon"
11+
spec:
12+
{{- if not .Values.autoscaling.enabled }}
13+
replicas: {{ .Values.replicaCount }}
14+
{{- end }}
15+
selector:
16+
matchLabels:
17+
app: {{ include "pontoon.fullname" . }}
18+
heritage: {{ .Release.Service }}
19+
release: {{ .Release.Name }}
20+
component: "pontoon"
21+
template:
22+
metadata:
23+
annotations:
24+
checksum/pontoon-secrets: {{ include (print $.Template.BasePath "/pontoon-secrets.yaml") . | sha256sum }}
25+
checksum/pontoon-ssh-secrets: {{ include (print $.Template.BasePath "/pontoon-ssh-secrets.yaml") . | sha256sum }}
26+
checksum/pontoon-settings: {{ include (print $.Template.BasePath "/pontoon-settings-configmap.yaml") . | sha256sum }}
27+
{{- range $key, $value := .Values.podAnnotations }}
28+
{{ $key }}: {{ $value | quote }}
29+
{{- end }}
30+
labels:
31+
app: {{ include "pontoon.fullname" . }}
32+
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
33+
heritage: {{ .Release.Service }}
34+
release: {{ .Release.Name }}
35+
component: "pontoon"
36+
spec:
37+
imagePullSecrets:
38+
{{- range .Values.imagePullSecrets }}
39+
- name: {{ .name | quote }}
40+
{{- end }}
41+
serviceAccountName: {{ include "pontoon.serviceAccountName" . }}
42+
securityContext:
43+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
44+
{{- if or .Values.ssh.config .Values.ssh.privateKeys }}
45+
initContainers:
46+
- name: copy-ssh-secrets
47+
image: "busybox"
48+
command:
49+
- "cp"
50+
- "-r"
51+
- "/ssh-data/."
52+
- {{ .Values.ssh.mountPath | quote }}
53+
volumeMounts:
54+
- mountPath: {{ .Values.ssh.mountPath | quote }}
55+
name: "dummy-volume"
56+
- mountPath: "/ssh-data"
57+
name: "pontoon-ssh"
58+
{{- end }}
59+
containers:
60+
- name: pontoon
61+
securityContext:
62+
{{- toYaml .Values.securityContext | nindent 12 }}
63+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
64+
imagePullPolicy: {{ .Values.image.pullPolicy }}
65+
ports:
66+
- name: http
67+
containerPort: 8000
68+
protocol: TCP
69+
command: ["gunicorn"]
70+
args:
71+
- "pontoon.wsgi:application"
72+
- "--bind=0.0.0.0"
73+
# TODO - add livenessProbe and readinessProbe
74+
# Pontoon does not seem to have a health check endpoint...
75+
# Maybe consider adding one to upstream
76+
resources:
77+
{{- toYaml .Values.resources | nindent 12 }}
78+
envFrom:
79+
- secretRef:
80+
name: "{{ include "pontoon.fullname" . }}-secrets"
81+
env:
82+
- name: SITE_URL
83+
value: {{ .Values.siteUrl | quote }}
84+
{{- include "common.tplvalues.render" (dict "value" .Values.defaultEnvVars "context" $) | nindent 12 }}
85+
{{- if .Values.extraSettingsModule }}
86+
- name: DJANGO_SETTINGS_MODULE
87+
value: "pontoon.settings.custom"
88+
{{- end }}
89+
{{- if .Values.extraEnvVars }}
90+
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
91+
{{- end }}
92+
volumeMounts:
93+
{{- if .Values.extraSettingsModule }}
94+
- mountPath: "{{ .Values.pontoonHome }}/pontoon/settings/custom.py"
95+
name: "pontoon-settings"
96+
subPath: "custom.py"
97+
{{- end }}
98+
{{- if or .Values.ssh.config .Values.ssh.privateKeys }}
99+
- name: "dummy-volume"
100+
mountPath: {{ .Values.ssh.mountPath | quote }}
101+
{{- end }}
102+
volumes:
103+
{{- if .Values.extraSettingsModule }}
104+
- name: "pontoon-settings"
105+
configMap:
106+
name: "{{ include "pontoon.fullname" . }}-settings-configmap"
107+
{{- end }}
108+
{{- if or .Values.ssh.config .Values.ssh.privateKeys }}
109+
- name: "pontoon-ssh"
110+
secret:
111+
secretName: "{{ include "pontoon.fullname" . }}-ssh-secrets"
112+
defaultMode: 420 # 0644
113+
- name: "dummy-volume"
114+
emptyDir: {}
115+
{{- end }}
116+
{{- with .Values.nodeSelector }}
117+
nodeSelector:
118+
{{- toYaml . | nindent 8 }}
119+
{{- end }}
120+
{{- with .Values.affinity }}
121+
affinity:
122+
{{- toYaml . | nindent 8 }}
123+
{{- end }}
124+
{{- with .Values.tolerations }}
125+
tolerations:
126+
{{- toYaml . | nindent 8 }}
127+
{{- end }}

0 commit comments

Comments
 (0)