1a0b04feec
- deployment.yaml with imagePullSecrets, health probes, WordPress volumes - db-deployment.yaml for PostgreSQL/MySQL with readiness/liveness probes - ingress.yaml with cert-manager TLS - registry-pull-secret.yaml for insecure registries - PVCs and secrets with helm.sh/resource-policy: keep - _helpers.tpl with shared template functions - values.yaml with comprehensive defaults
103 lines
3.4 KiB
YAML
103 lines
3.4 KiB
YAML
{{- if .Values.database.enabled }}
|
|
{{- $name := include "cloudhost-app.name" . -}}
|
|
{{- $ns := include "cloudhost-app.namespace" . -}}
|
|
{{- $dbName := include "cloudhost-app.dbDeploymentName" . -}}
|
|
{{- $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 }}
|
|
- 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 }}]
|
|
{{- 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 }}]
|
|
{{- else }}
|
|
exec:
|
|
command: ["mysqladmin", "ping", "-h", "127.0.0.1"]
|
|
{{- end }}
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
failureThreshold: 5
|
|
volumes:
|
|
- name: db-storage
|
|
persistentVolumeClaim:
|
|
claimName: {{ $dbName }}
|
|
{{- end }}
|