695e05f948
Introduce product types for managed PostgreSQL, Redis, and RabbitMQ with a dedicated dashboard, Helm-only deploy pipeline, external access, snapshots with progress, and prorated resource or storage upgrades matching application billing rules. PVCs use an expandable StorageClass with automatic migration when legacy disks cannot resize in place. Co-authored-by: Cursor <cursoragent@cursor.com>
149 lines
5.6 KiB
YAML
149 lines
5.6 KiB
YAML
{{- if .Values.database.enabled }}
|
|
{{- $name := include "cloudhost-app.name" . -}}
|
|
{{- $ns := include "cloudhost-app.namespace" . -}}
|
|
{{- $dbName := include "cloudhost-app.dbDeploymentName" . -}}
|
|
{{- $dbLogicalName := include "cloudhost-app.dbName" . -}}
|
|
{{- $dbPort := include "cloudhost-app.dbPort" . -}}
|
|
{{- $dbData := include "cloudhost-app.dbDataPath" . -}}
|
|
{{- $dbImg := include "cloudhost-app.dbImage" . -}}
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ $dbName }}
|
|
namespace: {{ $ns }}
|
|
labels:
|
|
app: {{ $dbName }}
|
|
{{- include "cloudhost-app.labels" . | nindent 4 }}
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: {{ $dbName }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: {{ $dbName }}
|
|
spec:
|
|
containers:
|
|
- name: {{ $dbName }}
|
|
image: {{ $dbImg }}
|
|
ports:
|
|
- containerPort: {{ include "cloudhost-app.dbPort" . | int }}
|
|
env:
|
|
{{- if eq .Values.database.type "postgresql" }}
|
|
- name: PGDATA
|
|
value: {{ include "cloudhost-app.pgDataDir" . }}
|
|
- name: POSTGRES_DB
|
|
value: {{ include "cloudhost-app.dbName" . }}
|
|
- name: POSTGRES_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: username
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: password
|
|
{{- else if eq .Values.database.type "mariadb" }}
|
|
- name: MARIADB_DATABASE
|
|
value: {{ include "cloudhost-app.dbName" . }}
|
|
- name: MARIADB_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: username
|
|
- name: MARIADB_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: password
|
|
- name: MARIADB_ROOT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: password
|
|
{{- else if eq .Values.database.type "mongodb" }}
|
|
- name: MONGO_INITDB_DATABASE
|
|
value: {{ include "cloudhost-app.dbName" . }}
|
|
- name: MONGO_INITDB_ROOT_USERNAME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: username
|
|
- name: MONGO_INITDB_ROOT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: password
|
|
{{- else }}
|
|
- name: MYSQL_DATABASE
|
|
value: {{ include "cloudhost-app.dbName" . }}
|
|
- name: MYSQL_USER
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: username
|
|
- name: MYSQL_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: password
|
|
- name: MYSQL_ROOT_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: {{ $name }}-db-secret
|
|
key: password
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: db-storage
|
|
mountPath: {{ $dbData }}
|
|
resources:
|
|
requests:
|
|
cpu: {{ .Values.database.resources.cpuRequest | quote }}
|
|
memory: {{ .Values.database.resources.memoryRequest | quote }}
|
|
limits:
|
|
cpu: {{ .Values.database.resources.cpuLimit | quote }}
|
|
memory: {{ .Values.database.resources.memoryLimit | quote }}
|
|
readinessProbe:
|
|
{{- if eq .Values.database.type "postgresql" }}
|
|
exec:
|
|
command: ["pg_isready", "-U", {{ .Values.database.username | quote }}, "-d", {{ $dbLogicalName | quote }}]
|
|
{{- else if eq .Values.database.type "mariadb" }}
|
|
exec:
|
|
command: ["healthcheck.sh", "--connect", "--innodb_initialized"]
|
|
{{- else if eq .Values.database.type "mongodb" }}
|
|
exec:
|
|
command: ["mongosh", "--eval", "db.adminCommand('ping')"]
|
|
{{- else }}
|
|
exec:
|
|
command: ["mysqladmin", "ping", "-h", "127.0.0.1"]
|
|
{{- end }}
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 5
|
|
failureThreshold: 6
|
|
livenessProbe:
|
|
{{- if eq .Values.database.type "postgresql" }}
|
|
exec:
|
|
command: ["pg_isready", "-U", {{ .Values.database.username | quote }}, "-d", {{ $dbLogicalName | quote }}]
|
|
{{- else if eq .Values.database.type "mariadb" }}
|
|
exec:
|
|
command: ["healthcheck.sh", "--connect", "--innodb_initialized"]
|
|
{{- else if eq .Values.database.type "mongodb" }}
|
|
exec:
|
|
command: ["mongosh", "--eval", "db.adminCommand('ping')"]
|
|
{{- else }}
|
|
exec:
|
|
command: ["mysqladmin", "ping", "-h", "127.0.0.1"]
|
|
{{- end }}
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
failureThreshold: 5
|
|
{{- include "cloudhost-app.logShipperContainers" (dict "root" . "workloadName" $dbName "workloadType" "database") | nindent 8 }}
|
|
volumes:
|
|
- name: db-storage
|
|
persistentVolumeClaim:
|
|
claimName: {{ $dbName }}
|
|
{{- include "cloudhost-app.logShipperVolumes" (dict "root" . "workloadName" $dbName) | nindent 8 }}
|
|
{{- end }}
|