feat(bridge): Add instagram

This commit is contained in:
Tanguy Herbron 2024-12-15 21:58:03 +01:00
parent 3a035e3927
commit b1012e0973
6 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,14 @@
#!/bin/bash
echo "Checking if $INSTAGRAM_DB database exists..."
if psql -lqt | cut -d \| -f 1 | grep -qw $INSTAGRAM_DB; then
echo "Database exists, skipping creation"
else
echo "Database does not exist, creating..."
createdb $INSTAGRAM_DB
createuser $INSTAGRAM_USER
psql -c "ALTER USER $INSTAGRAM_USER WITH ENCRYPTED PASSWORD '$INSTAGRAM_PASSWORD';"
psql -c "GRANT ALL PRIVILEGES ON DATABASE $INSTAGRAM_DB TO $INSTAGRAM_USER;"
psql -c "ALTER DATABASE $INSTAGRAM_DB OWNER TO $INSTAGRAM_USER;"
fi

View File

@ -0,0 +1,46 @@
apiVersion: batch/v1
kind: Job
metadata:
name: instagram-db-init
namespace: synapse
spec:
template:
spec:
containers:
- name: instagram-db-init
image: postgres:15.10
command: ["/bin/bash", "/data/create_db.sh"]
env:
- name: PGHOST
value: synapse-db-rw.synapse.svc.cluster.local
- name: PGUSER
valueFrom:
secretKeyRef:
name: synapse-db-superuser
key: username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: synapse-db-superuser
key: password
- name: INSTAGRAM_USER
valueFrom:
secretKeyRef:
name: mautrix-instagram-db
key: username
- name: INSTAGRAM_PASSWORD
valueFrom:
secretKeyRef:
name: mautrix-instagram-db
key: password
- name: INSTAGRAM_DB
value: instagram
volumeMounts:
- name: create-db
mountPath: /data
volumes:
- name: create-db
configMap:
name: instagram-db-creation
restartPolicy: Never
backoffLimit: 4

View File

@ -0,0 +1,18 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: synapse
resources:
- service.yaml
- statefulset.yaml
- job.yaml
generatorOptions:
labels:
app: messenger
configMapGenerator:
- name: messenger-db-creation
behavior: create
files:
- create_db.sh

View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: instagram
namespace: synapse
labels:
app.kubernetes.io/name: instagram
spec:
ports:
- name: http
port: 29319
protocol: TCP
targetPort: 29319
selector:
app: instagram
publishNotReadyAddresses: true

View File

@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: instagram
namespace: synapse
spec:
selector:
matchLabels:
app: instagram
serviceName: instagram
replicas: 1
minReadySeconds: 10
template:
metadata:
labels:
app: instagram
spec:
terminationGracePeriodSeconds: 10
containers:
- name: instagram
image: dock.mau.dev/mautrix/meta:v0.4.2
command: [
"/usr/bin/mautrix-meta",
"--config", "/data/config.yaml",
"--no-update",
]
ports:
- containerPort: 29328
volumeMounts:
- mountPath: "/data/config.yaml"
name: instagram-config-file
subPath: config.yaml
volumes:
- name: instagram-config-file
secret:
secretName: instagram-secret-config

View File

@ -4,3 +4,4 @@ kind: Kustomization
resources: resources:
- ./signal - ./signal
- ./messenger - ./messenger
- ./instagram