Skip to content

Commit 65a3b7d

Browse files
author
annanas
committed
✨(k8s) add jigasi scaling and transcription feature
We want to deploy jigasi on our kubernetes cluster. This enables transcription via VOSK. The settings are stored in .env files used by Kustomize to generate ConfigMaps. Values can be overriden in the overlay if necessary.
1 parent 6f110c0 commit 65a3b7d

19 files changed

+511
-13
lines changed

bin/init-overlay

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ JIBRI_RECORDER_PASSWORD=$(random_password 64)
3838
JIBRI_XMPP_PASSWORD=$(random_password 64)
3939
JICOFO_AUTH_PASSWORD=$(random_password 64)
4040
JVB_AUTH_PASSWORD=$(random_password 64)
41+
JIGASI_XMPP_PASSWORD=$(random_password 64)
4142
echo OK
4243

4344
export BASE_DOMAIN
4445
export JIBRI_RECORDER_PASSWORD
4546
export JIBRI_XMPP_PASSWORD
4647
export JICOFO_AUTH_PASSWORD
4748
export JVB_AUTH_PASSWORD
49+
export JIGASI_XMPP_PASSWORD
4850
export LETSENCRYPT_ACCOUNT_EMAIL
4951

5052
mkdir "$NEW_OVERLAY_PATH"

k8s/base/env/jigasi.env

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This disables Jigasi SIP connections
2+
JIGASI_DISABLE_SIP=false
3+
4+
# SIP password for jigasi
5+
JIGASI_SIP_PASSWORD=jigasi
6+
7+
#JIGASI_SIP_SERVER=
8+
9+
#Port and Transport method used for Jigasi SIP
10+
JIGASI_SIP_PORT=5060
11+
JIGASI_SIP_TRANSPORT=UDP
12+
13+
#JIGASI_SIP_DEFAULT_ROOM=
14+
#JIGASI_HEALTH_CHECK_SIP_URI=
15+
#JIGASI_HEALTH_CHECK_INTERVAL=
16+
#JIGASI_SIP_KEEP_ALIVE_METHOD=
17+
#JIGASI_ENABLE_SDES_SRTP=
18+
19+
JIGASI_TRANSCRIBER_ADVERTISE_URL=true
20+
21+
# Determines whether the transcriber records audio.
22+
JIGASI_TRANSCRIBER_RECORD_AUDIO=false
23+
24+
# This variable changes whether Jigasi sends the transcribed text in chat or not.
25+
JIGASI_TRANSCRIBER_SEND_TXT=false
26+
27+
# Custom transcription service to use with Jigasi
28+
JIGASI_CUSTOM_TRANSCRIPTION_SERVICE=org.jitsi.jigasi.transcription.VoskTranscriptionService
29+
30+
# Websocket for the VOSK transcription service
31+
VOSK_WEBSOCKET_URL=ws://127.0.0.1:2700

k8s/base/env/jitsi-common.env

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PUBLIC_URL=https://YOUR_DOMAIN
99
XMPP_DOMAIN=YOUR_DOMAIN
1010

1111
# Internal XMPP server
12-
XMPP_SERVER=prosody.jitsi.svc
12+
XMPP_SERVER=prosody.jitsi.svc.cluster.local
1313

1414
# Internal XMPP domain for authenticated services.
1515
XMPP_AUTH_DOMAIN=auth.YOUR_DOMAIN
@@ -23,9 +23,12 @@ XMPP_INTERNAL_MUC_DOMAIN=internal-muc.auth.YOUR_DOMAIN
2323
# XMPP domain for the MUC.
2424
XMPP_MUC_DOMAIN=muc.YOUR_DOMAIN
2525

26-
# XMPP domain for the jibri recorder
26+
# XMPP domain for the jibri and jigasi recorder
2727
XMPP_RECORDER_DOMAIN=recorder.YOUR_DOMAIN
2828

29+
# XMPP port
30+
XMPP_PORT=5222
31+
2932
# MUC for the JVB pool.
3033
JVB_BREWERY_MUC=jvbbrewery
3134

@@ -35,6 +38,9 @@ JIBRI_BREWERY_MUC=jibribrewery
3538
# MUC name for the Jigasi pool.
3639
JIGASI_BREWERY_MUC=jigasibrewery
3740

41+
# Jigasi SIP URI for jigasi and jicofo.
42+
JIGASI_SIP_URI=[email protected]_DOMAIN
43+
3844
# System time zone
3945
TZ=UTC
4046

@@ -62,6 +68,9 @@ ENABLE_AUTH=0
6268
# Enable guest access
6369
ENABLE_GUESTS=1
6470

71+
# Enable transcriptions
72+
ENABLE_TRANSCRIPTIONS=true
73+
6574
# Select authentication type: internal, jwt or ldap
6675
AUTH_TYPE=internal
6776

k8s/base/env/jitsi-meet-front.env

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ DISABLE_HTTPS=1
99
ENABLE_HTTP_REDIRECT=0
1010

1111
# Internal XMPP server URL
12-
XMPP_BOSH_URL_BASE=http://prosody.jitsi.svc:5280
12+
XMPP_BOSH_URL_BASE=http://prosody.jitsi.svc.cluster.local:5280
1313

1414
# Default language to use
15-
#DEFAULT_LANGUAGE=
15+
DEFAULT_LANGUAGE=en
1616

1717
# URL used to receive branding specific information in JSON.
1818
# None of the fields are mandatory and the response must have the shape:
@@ -243,7 +243,7 @@ ENABLE_STATS_ID=false
243243
# Nginx configuration
244244
#
245245

246-
NGINX_RESOLVER=127.0.0.1
246+
NGINX_RESOLVER=coredns.kube-system.svc.cluster.local
247247

248248
# Defines the number of worker processes.
249249
NGINX_WORKER_PROCESSES=4
@@ -252,4 +252,10 @@ NGINX_WORKER_PROCESSES=4
252252
# worker process. It should be kept in mind that this number includes all
253253
# connections (e.g. connections with proxied servers, among others), not only
254254
# connections with clients.
255-
NGINX_WORKER_CONNECTIONS=2048
255+
NGINX_WORKER_CONNECTIONS=768
256+
257+
#
258+
USE_APP_LANGUAGE=false
259+
260+
# Transcription languages available in the drop down menu
261+
TRANSLATION_LANGUAGES=["en"]

k8s/base/env/jitsi-secrets.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ JIBRI_XMPP_PASSWORD=
2222
# XMPP password for Jibri client connections.
2323
JIBRI_XMPP_USER=jibri
2424

25+
# XMPP user for Jigasi client connections.
26+
JIGASI_XMPP_USER=jigasi
27+
28+
#XMPP password for Jigasi client connections.
29+
JIGASI_XMPP_PASSWORD=
30+
2531
# Secret used to sign/verify JWT tokens
2632
#JWT_APP_SECRET=my_jitsi_app_secret
2733

k8s/base/jicofo-deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
spec:
1717
containers:
1818
- name: jitsi-meet
19-
image: jitsi/jicofo:stable-7648-4
19+
image: jitsi/jicofo:stable-8044
2020
imagePullPolicy: IfNotPresent
2121
envFrom:
2222
- configMapRef:

k8s/base/jigasi-deployment.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: jigasi
6+
name: jigasi
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: jigasi
11+
# The goal of this matchExpressions selector is to exclude the jigasi
12+
# pods with a label status=busy from their ReplicaSet.
13+
# A sidecar container (metadata-updater) is updating the status
14+
# label according to jibri's state.
15+
#
16+
# This mechanism drastically reduces the risk of terminating
17+
# a busy jibri pod when scaling down the deployment.
18+
#
19+
# For more details :
20+
# https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#isolating-pods-from-a-replicaset
21+
matchExpressions:
22+
- {key: status, operator: In, values: [idle, unknown]}
23+
strategy:
24+
rollingUpdate:
25+
maxSurge: 25%
26+
maxUnavailable: 1
27+
type: RollingUpdate
28+
template:
29+
metadata:
30+
annotations:
31+
labels:
32+
app: jigasi
33+
status: idle
34+
spec:
35+
serviceAccountName: jigasi
36+
containers:
37+
- image: annagrigoriu/testing:jigasi-transcription-final
38+
name: jigasi
39+
imagePullPolicy: Always
40+
ports:
41+
- containerPort: 20000
42+
protocol: UDP
43+
- containerPort: 8788
44+
name: api
45+
protocol: TCP
46+
envFrom:
47+
- configMapRef:
48+
name: jitsi-common
49+
- configMapRef:
50+
name: jigasi
51+
env:
52+
- name: JIGASI_XMPP_USER
53+
valueFrom:
54+
secretKeyRef:
55+
name: jitsi-secrets
56+
key: JIGASI_XMPP_USER
57+
- name: JIGASI_XMPP_PASSWORD
58+
valueFrom:
59+
secretKeyRef:
60+
name: jitsi-secrets
61+
key: JIGASI_XMPP_PASSWORD
62+
volumeMounts:
63+
- name: jigasi-transcripts
64+
mountPath: /tmp/transcripts
65+
- image: python:3.8
66+
name: metadata-updater
67+
command: ["/bin/sh","-c"]
68+
args: [ "pip install websockets && python3 opt/jigasi-metadata-updater/jigasi-metadata-updater.py"]
69+
volumeMounts:
70+
- name: jigasi-metadata-updater
71+
mountPath: /opt/jigasi-metadata-updater
72+
- image: alphacep/kaldi-en:latest
73+
name: vosk-en
74+
imagePullPolicy: Always
75+
ports:
76+
- containerPort: 2700
77+
nodeSelector:
78+
k8s.scaleway.com/pool-name: jigasi
79+
volumes:
80+
- name: jigasi-transcripts
81+
emptyDir: {}
82+
- name: jigasi-metadata-updater
83+
configMap:
84+
name: jigasi-metadata-updater

k8s/base/jigasi-hpa.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# With this Horizontal Pod Autoscaler, we want to ensure that there is
2+
# always at least:
3+
# - a specific count of jigasi pods available (TARGET_MIN_VALUE)
4+
# - a specific percentage of jigasi pods available across all jigasi pods (TARGET_PERCENT)
5+
#
6+
# The formula applied by HPA to compute the desired replicas is :
7+
# desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]
8+
# (see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details)
9+
#
10+
# If multiple metrics are specified in HPA, the formula is applied for each of
11+
# them and the higher desiredReplicas is taken into account.
12+
#
13+
# To guarantee that we always have at least TARGET_MIN_VALUE pods available, we
14+
# just have to set this value as minReplicas because the Deployment manages
15+
# only available jigasis. When a jigasi pod is busy, it gets orphaned and is
16+
# ignored by the Deployment.
17+
#
18+
# To ensure that we have a certain percentage of available pods
19+
# (TARGET_PERCENT), a rule is defined in this HPA based on the "jigasi_busy"
20+
# metric, which takes into account all jigasi pods in the namespace (those
21+
# managed by the deployment + the orphaned pods that are busy)
22+
23+
apiVersion: autoscaling/v2beta2
24+
kind: HorizontalPodAutoscaler
25+
metadata:
26+
name: jigasi-hpa
27+
spec:
28+
scaleTargetRef:
29+
apiVersion: apps/v1
30+
kind: Deployment
31+
name: jigasi
32+
minReplicas: 2
33+
maxReplicas: 10
34+
behavior:
35+
# We'll allow to scale down 20% of the pods every 30s
36+
scaleDown:
37+
stabilizationWindowSeconds: 60
38+
policies:
39+
- type: Percent
40+
value: 20
41+
periodSeconds: 30
42+
# We allow to add 2 pods every 2 minutes.
43+
# FIXME: Adjust this value when cluster autoscaler is enabled.
44+
# It should give enough time to provision new nodes, but not too much
45+
# to be able to scale-up in case of high demand.
46+
scaleUp:
47+
policies:
48+
- type: Pods
49+
value: 2
50+
periodSeconds: 120
51+
metrics:
52+
- type: Object
53+
object:
54+
metric:
55+
name: jigasi_busy
56+
describedObject:
57+
apiVersion: v1
58+
kind: Namespace
59+
name: jitsi
60+
target:
61+
type: Value
62+
# We want to always have at least 20% of available jigasi instances.
63+
value: 0.8

0 commit comments

Comments
 (0)