Skip to content
This repository was archived by the owner on Jul 8, 2021. It is now read-only.

Commit

Permalink
Add initial helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Oct 22, 2019
1 parent 36924ba commit 6e7e788
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
/build
/dist

*.yaml
config.yaml
registration.yaml
!example-config.yaml

*.log
Expand Down
2 changes: 2 additions & 0 deletions helm/mautrix-twilio/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.{yaml,yml}]
indent_size = 2
22 changes: 22 additions & 0 deletions helm/mautrix-twilio/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
15 changes: 15 additions & 0 deletions helm/mautrix-twilio/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
name: mautrix-twilio
version: 0.1.0
appVersion: "0.1.0"
description: A Matrix-Twilio relaybot bridge.
keywords:
- matrix
- bridge
- twilio
- whatsapp
maintainers:
- name: Tulir Asokan
email: [email protected]
sources:
- https://github.com/tulir/mautrix-twilio
21 changes: 21 additions & 0 deletions helm/mautrix-twilio/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Your registration file is below. Save it into a YAML file and give the path to that file to synapse:

id: {{ .Values.appservice.id }}
as_token: {{ .Values.appservice.asToken }}
hs_token: {{ .Values.appservice.hsToken }}
namespaces:
users:
- exclusive: true
regex: "@{{ .Values.bridge.username_template | replace "{userid}" ".+"}}:{{ .Values.homeserver.domain }}"
{{- if .Values.appservice.communityID }}
group_id: {{ .Values.appservice.communityID }}
{{- end }}
aliases:
- exclusive: true
regex: "@{{ .Values.bridge.alias_template | replace "{groupname}" ".+"}}:{{ .Values.homeserver.domain }}"
{{- if .Values.appservice.communityID }}
group_id: {{ .Values.appservice.communityID }}
{{- end }}
url: {{ .Values.appservice.address }}
sender_localpart: {{ .Values.appservice.botUsername }}
rate_limited: false
55 changes: 55 additions & 0 deletions helm/mautrix-twilio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mautrix-twilio.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 "mautrix-twilio.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 "mautrix-twilio.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "mautrix-twilio.labels" -}}
app.kubernetes.io/name: {{ include "mautrix-twilio.name" . }}
helm.sh/chart: {{ include "mautrix-twilio.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "mautrix-twilio.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "mautrix-twilio.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
51 changes: 51 additions & 0 deletions helm/mautrix-twilio/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "mautrix-twilio.fullname" . }}
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ template "mautrix-twilio.name" . }}
data:
config.yaml: |
homeserver:
address: {{ .Values.homeserver.address }}
public_address: {{ .Values.homeserver.publicAddress }}
domain: {{ .Values.homeserver.domain }}
verify_ssl: {{ .Values.homeserver.verifySSL }}
appservice:
address: http://{{ include "mautrix-twilio.fullname" . }}:{{ .Values.service.port }}
hostname: 0.0.0.0
port: {{ .Values.service.port }}
max_body_size: {{ .Values.appservice.maxBodySize }}
database: {{ .Values.appservice.database }}
public:
{{- toYaml .Values.appservice.public | nindent 8 }}
provisioning:
{{- toYaml .Values.appservice.provisioning | nindent 8 }}
id: {{ .Values.appservice.id }}
bot_username: {{ .Values.appservice.botUsername }}
bot_displayname: {{ .Values.appservice.botDisplayname }}
bot_avatar: {{ .Values.appservice.botAvatar }}
community_id: {{ .Values.appservice.communityID }}
as_token: {{ .Values.appservice.asToken }}
hs_token: {{ .Values.appservice.hsToken }}
bridge:
{{- toYaml .Values.bridge | nindent 6 }}
twilio:
{{- toYaml .Values.twilio | nindent 6 }}
logging:
{{- toYaml .Values.logging | nindent 6 }}
registration.yaml: ""
65 changes: 65 additions & 0 deletions helm/mautrix-twilio/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mautrix-twilio.fullname" . }}
labels:
{{- include "mautrix-twilio.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ include "mautrix-twilio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
{{- if .Values.podAnnotations }}
annotations:
{{- toYaml .Values.podAnnotations | nindent 6 }}
{{- end }}
metadata:
labels:
app.kubernetes.io/name: {{ include "mautrix-twilio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
serviceAccountName: {{ template "mautrix-twilio.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- mountPath: /data
name: config-volume
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
# livenessProbe:
# httpGet:
# path: /
# port: http
# readinessProbe:
# httpGet:
# path: /
# port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: config-volume
configMap:
name: {{ template "mautrix-twilio.fullname" . }}

securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
16 changes: 16 additions & 0 deletions helm/mautrix-twilio/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mautrix-twilio.fullname" . }}
labels:
{{ include "mautrix-twilio.labels" . | indent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "mautrix-twilio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
8 changes: 8 additions & 0 deletions helm/mautrix-twilio/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "mautrix-twilio.serviceAccountName" . }}
labels:
{{ include "mautrix-twilio.labels" . | indent 4 }}
{{- end -}}
117 changes: 117 additions & 0 deletions helm/mautrix-twilio/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
image:
repository: dock.mau.dev/tulir/mautrix-twilio
tag: latest
pullPolicy: IfNotPresent

nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:

service:
type: ClusterIP
port: 29322

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

# Homeserver details
homeserver:
# The address that this appservice can use to connect to the homeserver.
address: https://example.com
# The address that Twilio can use to download media from the homeserver.
publicAddress: https://matrix.example.com
# The domain of the homeserver (for MXIDs, etc).
domain: example.com
# Whether or not to verify the SSL certificate of the homeserver.
# Only applies if address starts with https://
verifySSL: true

# Application service host/registration related details
# Changing these values requires regeneration of the registration.
appservice:
# The full URI to the database. SQLite and Postgres are fully supported.
# Other DBMSes supported by SQLAlchemy may or may not work.
# Format examples:
# SQLite: sqlite:///filename.db
# Postgres: postgres://username:password@hostname/dbname
database: postgres://username:password@hostname/dbname

# The maximum body size of appservice API requests (from the homeserver) in mebibytes
# Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s
maxBodySize: 1

id: twilio
botUsername: twiliobot
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
# to leave display name/avatar as-is.
botDisplayname: Twilio bridge bot
botAvatar: mxc://maunium.net/FYuKJHaCrSeSpvBJfHwgYylP

# Community ID for bridged users (changes registration file) and rooms.
# Must be created manually.
communityID: false

# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
asToken: SET TO RANDOM STRING
hsToken: SET TO RANDOM STRING

# The keys below can be used to override the configs in the base config:
# https://github.com/tulir/mautrix-twilio/blob/master/example-config.yaml
# Note that the "appservice" and "homeserver" sections are above and slightly different than the base.

# Bridge config
bridge:
# Localpart template of MXIDs for remote users.
# {userid} is replaced with the phone number of the user (plain/E.164 international format).
username_template: "twilio_whatsapp_{userid}"
# Displayname template for remote users.
# {displayname} is replaced with the phone number of the user (human-readable international format).
alias_template: "twilio_whatsapp_{groupname}"

# List of users to always invite to newly created portal rooms.
invite_users: []

# Permissions for using the bridge.
# Permitted values:
# user - Use the bridge with puppeting.
# admin - Use and administrate the bridge.
# Permitted keys:
# * - All Matrix users
# domain - All users on that homeserver
# mxid - Specific user
permissions:
"example.com": "user"
"@admin:example.com": "admin"

# Twilio webhook settings.
twilio:
# Twilio account ID
account_id: AC1082dcd0e9ae51404f6cae3581edfbff
# Twilio phone number to send messages from.
sender_id: whatsapp:+1415550199
# Your Twilio auth token (get from Twilio dashboard front page)
secret: 2035141f21a001604e763c009aa3be4c
# Path prefix for webhook endpoints. Subpaths are /status and /receive.
# Note that the webhook must be put behind a reverse proxy with https.
webhook_path: /twilio

0 comments on commit 6e7e788

Please sign in to comment.