312 lines
10 KiB
YAML
312 lines
10 KiB
YAML
{{- if .Values.mumble.enabled }}
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: mumble
|
|
labels:
|
|
app.kubernetes.io/name: mumble
|
|
{{- with .Values.service.annotations }}
|
|
annotations:
|
|
{{ toYaml . | indent 4 }}
|
|
{{- end }}
|
|
spec:
|
|
type: {{ .Values.service.type }}
|
|
{{- if eq .Values.service.type "LoadBalancer" }}
|
|
loadBalancerIP: {{ .Values.service.loadBalancerIP | quote }}
|
|
{{- end }}
|
|
{{- if eq .Values.service.type "LoadBalancer" }}
|
|
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
|
|
{{- end }}
|
|
selector:
|
|
app.kubernetes.io/name: mumble
|
|
ports:
|
|
- name: mumble-tcp
|
|
port: 64738
|
|
targetPort: mumble-tcp
|
|
protocol: TCP
|
|
- name: mumble-udp
|
|
port: 64738
|
|
targetPort: mumble-udp
|
|
protocol: UDP
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: mumble
|
|
labels:
|
|
app.kubernetes.io/name: mumble
|
|
spec:
|
|
replicas: 1
|
|
# Two Mumble processes must not serve the same virtual server/database.
|
|
strategy:
|
|
type: Recreate
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: mumble
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: mumble
|
|
spec:
|
|
# Allows the certificate watcher to send SIGUSR1 to mumble-server.
|
|
shareProcessNamespace: true
|
|
automountServiceAccountToken: false
|
|
terminationGracePeriodSeconds: 30
|
|
securityContext:
|
|
fsGroup: 10000
|
|
fsGroupChangePolicy: OnRootMismatch
|
|
initContainers:
|
|
- name: render-config
|
|
image: {{ .Values.images.busybox | quote }}
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- /bin/sh
|
|
- -ec
|
|
- |
|
|
umask 077
|
|
cat > /config/mumble-server.ini <<EOF
|
|
database=mumble
|
|
dbDriver=QPSQL
|
|
dbUsername=mumble
|
|
dbPassword=$MUMBLE_DB_PASSWORD
|
|
dbHost=$MUMBLE_DB_HOST
|
|
dbPort=5432
|
|
ice="tcp -h 127.0.0.1 -p 6502"
|
|
logfile=
|
|
welcometext="$MUMBLE_WELCOME_TEXT"
|
|
port=64738
|
|
bandwidth=558000
|
|
users=100
|
|
messageburst=5
|
|
messagelimit=1
|
|
allowping=true
|
|
registerName=$MUMBLE_REGISTRATION_NAME
|
|
registerPassword=$MUMBLE_REGISTRATION_PASSWORD
|
|
registerUrl=$MUMBLE_REGISTRATION_URL
|
|
registerHostname=$MUMBLE_REGISTRATION_HOSTNAME
|
|
registerLocation=$MUMBLE_REGISTRATION_LOCATION
|
|
sslCert=/certs/tls.crt
|
|
sslKey=/certs/tls.key
|
|
|
|
[Ice]
|
|
Ice.Warn.UnknownProperties=1
|
|
Ice.MessageSizeMax=65536
|
|
EOF
|
|
env:
|
|
- name: MUMBLE_DB_HOST
|
|
value: {{ .Values.database.host | quote }}
|
|
- name: MUMBLE_WELCOME_TEXT
|
|
value: {{ .Values.config.welcomeText | quote }}
|
|
- name: MUMBLE_REGISTRATION_NAME
|
|
value: {{ .Values.config.registrationName | quote }}
|
|
- name: MUMBLE_REGISTRATION_URL
|
|
value: {{ .Values.config.registrationURL | quote }}
|
|
- name: MUMBLE_REGISTRATION_HOSTNAME
|
|
value: {{ .Values.config.registrationHostname | quote }}
|
|
- name: MUMBLE_REGISTRATION_LOCATION
|
|
value: {{ .Values.config.registrationLocation | quote }}
|
|
- name: MUMBLE_DB_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Values.secrets.mumble | quote }}
|
|
key: database-password
|
|
- name: MUMBLE_REGISTRATION_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Values.secrets.mumble | quote }}
|
|
key: registration-password
|
|
volumeMounts:
|
|
- name: config
|
|
mountPath: /config
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop:
|
|
- ALL
|
|
runAsNonRoot: true
|
|
runAsUser: 10000
|
|
runAsGroup: 10000
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
resources:
|
|
requests:
|
|
cpu: 1m
|
|
memory: 2Mi
|
|
limits:
|
|
cpu: 20m
|
|
memory: 16Mi
|
|
{{- if and (not .Values.postgresql.enabled) .Values.database.bootstrap.enabled }}
|
|
- name: bootstrap-postgresql
|
|
image: {{ .Values.images.postgresqlClient | quote }}
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- /bin/bash
|
|
- -ec
|
|
- |
|
|
psql \
|
|
--host="$MUMBLE_DB_HOST" \
|
|
--port=5432 \
|
|
--username=postgres \
|
|
--dbname=postgres \
|
|
--set=ON_ERROR_STOP=1 \
|
|
--set=mumble_password="$MUMBLE_DB_PASSWORD" <<'SQL'
|
|
SELECT format('CREATE ROLE %I LOGIN PASSWORD %L', 'mumble', :'mumble_password')
|
|
WHERE NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = 'mumble')
|
|
\gexec
|
|
SELECT format('ALTER ROLE %I LOGIN PASSWORD %L', 'mumble', :'mumble_password')
|
|
\gexec
|
|
SELECT format('CREATE DATABASE %I OWNER %I', 'mumble', 'mumble')
|
|
WHERE NOT EXISTS (SELECT FROM pg_catalog.pg_database WHERE datname = 'mumble')
|
|
\gexec
|
|
ALTER DATABASE mumble OWNER TO mumble;
|
|
REVOKE ALL ON DATABASE mumble FROM PUBLIC;
|
|
GRANT ALL PRIVILEGES ON DATABASE mumble TO mumble;
|
|
SQL
|
|
env:
|
|
- name: MUMBLE_DB_HOST
|
|
value: {{ .Values.database.host | quote }}
|
|
- name: PGPASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Values.secrets.postgresql | quote }}
|
|
key: postgres-password
|
|
- name: MUMBLE_DB_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Values.secrets.mumble | quote }}
|
|
key: database-password
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop:
|
|
- ALL
|
|
runAsNonRoot: true
|
|
runAsUser: 1001
|
|
runAsGroup: 1001
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
resources:
|
|
requests:
|
|
cpu: 10m
|
|
memory: 32Mi
|
|
limits:
|
|
cpu: 200m
|
|
memory: 128Mi
|
|
{{- end }}
|
|
containers:
|
|
- name: mumble
|
|
image: {{ printf "%s:%s" .Values.image.repository (.Values.image.tag | default .Chart.AppVersion) | quote }}
|
|
imagePullPolicy: IfNotPresent
|
|
ports:
|
|
- name: mumble-tcp
|
|
containerPort: 64738
|
|
protocol: TCP
|
|
- name: mumble-udp
|
|
containerPort: 64738
|
|
protocol: UDP
|
|
env:
|
|
- name: MUMBLE_CHOWN_DATA
|
|
value: "false"
|
|
- name: MUMBLE_CUSTOM_CONFIG_FILE
|
|
value: /config/mumble-server.ini
|
|
- name: MUMBLE_SUPERUSER_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ .Values.secrets.mumble | quote }}
|
|
key: superuser-password
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /data
|
|
- name: config
|
|
mountPath: /config
|
|
readOnly: true
|
|
- name: certificate
|
|
mountPath: /certs
|
|
readOnly: true
|
|
readinessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/bash
|
|
- -ec
|
|
- >-
|
|
awk '$2 ~ /:FCE2$/ && $4 == "0A" { found=1 }
|
|
END { exit(found ? 0 : 1) }' /proc/net/tcp /proc/net/tcp6
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
timeoutSeconds: 3
|
|
failureThreshold: 6
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- /bin/bash
|
|
- -ec
|
|
- >-
|
|
awk '$2 ~ /:FCE2$/ && $4 == "0A" { found=1 }
|
|
END { exit(found ? 0 : 1) }' /proc/net/tcp /proc/net/tcp6
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 20
|
|
timeoutSeconds: 3
|
|
failureThreshold: 3
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop:
|
|
- ALL
|
|
runAsNonRoot: true
|
|
runAsUser: 10000
|
|
runAsGroup: 10000
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
resources:
|
|
{{ toYaml .Values.resources | indent 12 }}
|
|
- name: certificate-reloader
|
|
image: {{ .Values.images.busybox | quote }}
|
|
imagePullPolicy: IfNotPresent
|
|
command:
|
|
- /bin/sh
|
|
- -ec
|
|
- |
|
|
previous="$(sha256sum /certs/tls.crt /certs/tls.key)"
|
|
while sleep 60; do
|
|
current="$(sha256sum /certs/tls.crt /certs/tls.key)"
|
|
if [ "$current" != "$previous" ]; then
|
|
set -- $(pidof mumble-server)
|
|
if [ "$#" -gt 0 ]; then
|
|
kill -USR1 "$@"
|
|
echo "Reloaded Mumble TLS certificate"
|
|
fi
|
|
previous="$current"
|
|
fi
|
|
done
|
|
volumeMounts:
|
|
- name: certificate
|
|
mountPath: /certs
|
|
readOnly: true
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop:
|
|
- ALL
|
|
runAsNonRoot: true
|
|
runAsUser: 10000
|
|
runAsGroup: 10000
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
resources:
|
|
requests:
|
|
cpu: 1m
|
|
memory: 2Mi
|
|
limits:
|
|
memory: 16Mi
|
|
volumes:
|
|
# PostgreSQL stores Mumble's durable state; /data only holds generated config.
|
|
- name: data
|
|
emptyDir: {}
|
|
- name: config
|
|
emptyDir: {}
|
|
- name: certificate
|
|
secret:
|
|
secretName: {{ .Values.secrets.tls | quote }}
|
|
defaultMode: 0440
|
|
{{- end }}
|