Add MongoDB initialization script and update deployment configurations

This commit is contained in:
Elmar Kresse
2025-06-17 17:26:10 +02:00
parent ffbd5a0991
commit c53a087f1e
8 changed files with 36 additions and 8 deletions

View File

@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mongo-init-script
namespace: overleaf
data:
mongodb-init.js: |
rs.initiate({ _id: 'overleaf', members: [{ _id: 0, host: 'mongo:27017' }] })

View File

@@ -12,12 +12,18 @@ spec:
labels: labels:
app: mongo app: mongo
spec: spec:
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "mongo"
securityContext: securityContext:
runAsUser: 1001 runAsUser: 1001
fsGroup: 0 fsGroup: 0
containers: containers:
- name: mongo - name: mongo
image: {{ .Values.mongo.image }} image: {{ .Values.mongo.image }}
command: ["mongod"]
args: ["--replSet", "{{ .Values.mongo.replSet }}"]
ports: ports:
- containerPort: {{ .Values.mongo.port }} - containerPort: {{ .Values.mongo.port }}
env: env:
@@ -36,6 +42,9 @@ spec:
volumeMounts: volumeMounts:
- name: mongo-data - name: mongo-data
mountPath: {{ .Values.mongo.volumeMounts.db }} mountPath: {{ .Values.mongo.volumeMounts.db }}
- name: mongo-init
mountPath: /docker-entrypoint-initdb.d/mongo-init.js
subPath: mongo-init.js
resources: resources:
requests: requests:
cpu: {{ .Values.resources.mongo.requests.cpu }} cpu: {{ .Values.resources.mongo.requests.cpu }}
@@ -46,4 +55,7 @@ spec:
volumes: volumes:
- name: mongo-data - name: mongo-data
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ .Values.persistence.mongoData }} claimName: {{ .Values.persistence.mongoData }}
- name: mongo-init
configMap:
name: mongo-init-script

View File

@@ -23,7 +23,7 @@ spec:
- name: OVERLEAF_SITE_LANGUAGE - name: OVERLEAF_SITE_LANGUAGE
value: {{ .Values.overleaf.siteLanguage | quote }} value: {{ .Values.overleaf.siteLanguage | quote }}
- name: OVERLEAF_MONGO_URL - name: OVERLEAF_MONGO_URL
value: 'mongodb://{{ .Values.mongo.rootUser }}:{{ .Values.mongo.rootPassword }}@mongo:27017/{{ .Values.mongo.initDb }}?replicaSet={{ .Values.mongo.replSet }}' value: 'mongodb://{{ .Values.mongo.rootUser | quote }}:{{ .Values.mongo.rootPassword | quote }}@{{ .Values.mongo.host | quote }}:{{ .Values.mongo.port }}/{{ .Values.mongo.initDb | quote }}?authSource=admin&replicaSet={{ .Values.mongo.replSet | quote }}'
- name: OVERLEAF_REDIS_HOST - name: OVERLEAF_REDIS_HOST
value: redis value: redis
- name: REDIS_HOST - name: REDIS_HOST

View File

@@ -3,11 +3,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: overleaf-ingress name: overleaf-ingress
annotations: namespace: {{ .Release.Namespace }}
kubernetes.io/ingress.class: "traefik"
cert-manager.io/cluster-issuer: "{{ .Values.ingress.certManagerIssuer }}"
# Traefik spezifisch: Enable HTTPS redirect (optional)
traefik.ingress.kubernetes.io/redirect-entry-point: websecure
spec: spec:
tls: tls:
- hosts: - hosts:
@@ -18,7 +14,7 @@ spec:
http: http:
paths: paths:
- path: / - path: /
pathType: Prefix pathType: ImplementationSpecific
backend: backend:
service: service:
name: overleaf name: overleaf

View File

@@ -2,9 +2,18 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: mongo name: mongo
namespace: {{ .Values.namespace }}
labels:
app: mongo
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec: spec:
type: ClusterIP
ports: ports:
- port: {{ .Values.mongo.port }} - port: {{ .Values.mongo.port }}
targetPort: {{ .Values.mongo.port }} targetPort: {{ .Values.mongo.port }}
protocol: TCP
name: mongo
selector: selector:
app: mongo app: mongo

View File

@@ -3,6 +3,7 @@ kind: Service
metadata: metadata:
name: redis name: redis
spec: spec:
type: ClusterIP
ports: ports:
- port: {{ .Values.redis.port }} - port: {{ .Values.redis.port }}
targetPort: {{ .Values.redis.port }} targetPort: {{ .Values.redis.port }}

View File

@@ -7,5 +7,6 @@ spec:
ports: ports:
- port: 80 - port: 80
targetPort: {{ .Values.overleaf.port }} targetPort: {{ .Values.overleaf.port }}
protocol: TCP
selector: selector:
app: overleaf app: overleaf

View File

@@ -23,6 +23,7 @@ mongo:
port: 27017 port: 27017
replSet: overleaf replSet: overleaf
initDb: overleaf initDb: overleaf
host: mongo
volumeMounts: volumeMounts:
db: /data/db db: /data/db
rootUser: root rootUser: root