1
0
mirror of https://github.com/alexandrev/xslt-lab.git synced 2026-09-16 18:23:16 +00:00

Make Firebase and storage optional

This commit is contained in:
2025-07-03 18:21:21 +02:00
parent a1f81ee732
commit ddddfbba79
6 changed files with 37 additions and 15 deletions
+4 -1
View File
@@ -103,7 +103,7 @@ This starts the backend on port `8000`, the frontend on `3000` and a PostgreSQL
## Helm Chart
A Helm chart is provided under `charts/xslt-playground` to deploy the frontend and backend on Kubernetes. Before installing, create a secret with your Firebase credentials:
A Helm chart is provided under `charts/xslt-playground` to deploy the frontend and backend on Kubernetes. By default it expects Firebase credentials and a PostgreSQL database. Before installing, create a secret with your Firebase credentials:
```bash
kubectl create secret generic firebase-config \
@@ -115,5 +115,8 @@ Install the chart with:
```bash
helm install xslt charts/xslt-playground
# Disable Firebase or database support if desired
# helm install xslt charts/xslt-playground --set firebase.enabled=false
# helm install xslt charts/xslt-playground --set storage.enabled=false
```
+9 -7
View File
@@ -7,16 +7,18 @@ This chart deploys the frontend and backend of xslt-playground.
Key parameters in `values.yaml`:
- `image.frontend` and `image.backend` container images.
- `firebaseSecretName` name of the secret containing Firebase credentials.
- `firebase.credentialsKey` is mounted for the backend and referenced by
`GOOGLE_APPLICATION_CREDENTIALS`.
- `firebase.configKey` is used for the `VITE_FIREBASE_CONFIG` environment
variable of the frontend.
- `databaseUrl` connection string used by the backend.
- `firebase.enabled` set to `false` to disable Firebase integration entirely.
When enabled you must provide a secret named by `firebase.secretName` with the
keys `firebase.credentialsKey` and `firebase.configKey`. The backend mounts the
credentials file at `firebase.credentialsMountPath` and the frontend reads the
config JSON.
- `storage.enabled` disable database usage when `false`. If enabled the backend
gets `DATABASE_URL` from `storage.databaseUrl`; otherwise the environment
variable `DISABLE_DATABASE=true` is set.
- `ingress` configure ingress for the frontend service.
- `hpa` enable CPU-based autoscaling for both deployments.
Create the secret before installing the chart:
When `firebase.enabled` is true you must create the secret before installing the chart:
```bash
kubectl create secret generic firebase-config \
@@ -21,21 +21,32 @@ spec:
image: "{{ .Values.image.backend.repository }}:{{ .Values.image.backend.tag }}"
imagePullPolicy: {{ .Values.image.backend.pullPolicy }}
env:
{{- if .Values.storage.enabled }}
- name: DATABASE_URL
value: {{ .Values.databaseUrl | quote }}
value: {{ .Values.storage.databaseUrl | quote }}
{{- else }}
- name: DISABLE_DATABASE
value: "true"
{{- end }}
{{- if .Values.firebase.enabled }}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: {{ printf "%s/%s" .Values.firebase.credentialsMountPath .Values.firebase.credentialsKey | quote }}
{{- end }}
volumeMounts:
{{- if .Values.firebase.enabled }}
- name: firebase
mountPath: {{ .Values.firebase.credentialsMountPath }}
readOnly: true
{{- end }}
ports:
- containerPort: {{ .Values.service.backend.port }}
{{- if .Values.firebase.enabled }}
volumes:
- name: firebase
secret:
secretName: {{ .Values.firebaseSecretName }}
secretName: {{ .Values.firebase.secretName }}
items:
- key: {{ .Values.firebase.credentialsKey }}
path: {{ .Values.firebase.credentialsKey }}
{{- end }}
@@ -23,11 +23,13 @@ spec:
env:
- name: VITE_BACKEND_URL
value: http://{{ include "xslt-playground.fullname" . }}-backend:{{ .Values.service.backend.port }}
{{- if .Values.firebase.enabled }}
- name: VITE_FIREBASE_CONFIG
valueFrom:
secretKeyRef:
name: {{ .Values.firebaseSecretName }}
name: {{ .Values.firebase.secretName }}
key: {{ .Values.firebase.configKey }}
{{- end }}
ports:
- containerPort: {{ .Values.service.frontend.port }}
resources: {{- toYaml .Values.resources.frontend | nindent 12 }}
+3 -1
View File
@@ -1,11 +1,13 @@
{{- if .Values.firebase.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.firebaseSecretName }}
name: {{ .Values.firebase.secretName }}
labels:
{{- include "xslt-playground.labels" . | nindent 4 }}
type: Opaque
data:
{{ .Values.firebase.credentialsKey }}: {{ .Values.firebase.credentials | default "" | b64enc | quote }}
{{ .Values.firebase.configKey }}: {{ .Values.firebase.config | default "" | b64enc | quote }}
{{- end }}
+5 -3
View File
@@ -47,12 +47,14 @@ hpa:
maxReplicas: 5
targetCPUUtilizationPercentage: 80
firebaseSecretName: firebase-config
firebase:
enabled: true
secretName: firebase-config
credentialsKey: service-account.json
configKey: firebase-config.json
credentialsMountPath: /var/secrets/firebase
# Example database URL
databaseUrl: postgres://postgres:postgres@db/xslt?sslmode=disable
storage:
enabled: true
databaseUrl: postgres://postgres:postgres@db/xslt?sslmode=disable