2025-03-12 13:52:15 +01:00

179 lines
7.0 KiB
YAML

{{- if .Values.analytics.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "supabase.analytics.fullname" . }}
labels:
{{- include "supabase.labels" . | nindent 4 }}
spec:
{{- if not .Values.analytics.autoscaling.enabled }}
replicas: {{ .Values.analytics.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "supabase.analytics.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.analytics.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "supabase.analytics.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.analytics.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "supabase.analytics.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.analytics.podSecurityContext | nindent 8 }}
initContainers:
- name: init-db
image: postgres:15-alpine
imagePullPolicy: IfNotPresent
env:
- name: DB_HOST
{{- if .Values.db.enabled }}
value: {{ include "supabase.db.fullname" . | quote }}
{{- else }}
value: {{ .Values.analytics.environment.DB_HOST | quote }}
{{- end }}
- name: DB_USER
valueFrom:
secretKeyRef:
{{- if .Values.secret.db.secretRef }}
name: {{ .Values.secret.db.secretRef }}
key: {{ .Values.secret.db.secretRefKey.username | default "username" }}
{{- else }}
name: {{ include "supabase.secret.db" . }}
key: username
{{- end }}
- name: DB_PORT
value: {{ .Values.analytics.environment.DB_PORT | quote }}
command: ["/bin/sh", "-c"]
args:
- |
until pg_isready -h $(DB_HOST) -p $(DB_PORT) -U $(DB_USER); do
echo "Waiting for database to start..."
sleep 2
done
- echo "Database is ready"
containers:
- name: {{ include "supabase.analytics.name" $ }}
securityContext:
{{- toYaml .Values.analytics.securityContext | nindent 12 }}
image: "{{ .Values.analytics.image.repository }}:{{ .Values.analytics.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.analytics.image.pullPolicy }}
env:
{{- range $key, $value := .Values.analytics.environment }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.db.enabled }}
- name: DB_HOSTNAME
value: {{ include "supabase.db.fullname" . }}
{{- end }}
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.secret.db.secretRef }}
name: {{ .Values.secret.db.secretRef }}
key: {{ .Values.secret.db.secretRefKey.password | default "password" }}
{{- else }}
name: {{ include "supabase.secret.db" . }}
key: password
{{- end }}
- name: DB_PASSWORD_ENC
valueFrom:
secretKeyRef:
{{- if .Values.secret.db.secretRef }}
name: {{ .Values.secret.db.secretRef }}
key: {{ .Values.secret.db.secretRefKey.password | default "password" }}
{{- else }}
name: {{ include "supabase.secret.db" . }}
key: password_encoded
{{- end }}
- name: DB_DATABASE
valueFrom:
secretKeyRef:
{{- if .Values.secret.db.secretRef }}
name: {{ .Values.secret.db.secretRef }}
key: {{ .Values.secret.db.secretRefKey.database | default "database" }}
{{- else }}
name: {{ include "supabase.secret.db" . }}
key: database
{{- end }}
- name: LOGFLARE_API_KEY
valueFrom:
secretKeyRef:
{{- if .Values.secret.analytics.secretRef }}
name: {{ .Values.secret.analytics.secretRef }}
key: {{ .Values.secret.analytics.secretRefKey.apiKey | default "apiKey" }}
{{- else }}
name: {{ include "supabase.secret.analytics" . }}
key: apiKey
{{- end }}
{{- if .Values.analytics.bigQuery.enabled }}
- name: GOOGLE_PROJECT_ID
value: {{ .Values.analytics.bigQuery.projectId | quote }}
- name: GOOGLE_PROJECT_NUMBER
value: {{ .Values.analytics.bigQuery.projectNumber | quote }}
{{- else }}
- name: POSTGRES_BACKEND_URL
value: $(DB_DRIVER)://$(DB_USERNAME):$(DB_PASSWORD_ENC)@$(DB_HOSTNAME):$(DB_PORT)/$(DB_DATABASE)
- name: POSTGRES_BACKEND_SCHEMA
value: $(DB_SCHEMA)
- name: LOGFLARE_FEATURE_FLAG_OVERRIDE
value: $(FEATURE_FLAG_OVERRIDE)
{{- end }}
{{- with .Values.analytics.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.analytics.readinessProbe }}
readinessProbe:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- containerPort: {{ .Values.analytics.service.port }}
protocol: TCP
{{- if or (.Values.analytics.bigQuery.enabled) (.Values.analytics.volumes) }}
volumeMounts:
{{- with .Values.analytics.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.analytics.bigQuery.enabled }}
- mountPath: /opt/app/rel/logflare/bin/gcloud.json
name: gcloud-credentials
subPath: gcloud.json
{{- end }}
{{- end }}
{{- with .Values.analytics.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or (.Values.analytics.bigQuery.enabled) (.Values.analytics.volumes) }}
volumes:
{{- with .Values.analytics.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.analytics.bigQuery.enabled }}
- name: gcloud-credentials
secret:
secretName: {{ include "supabase.analytics.fullname" . }}-gcloud
{{- end }}
{{- end }}
{{- with .Values.analytics.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.analytics.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.analytics.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}