add app init files

This commit is contained in:
2026-08-11 16:06:22 +03:00
parent 4525d60385
commit 9f0c613768
16 changed files with 672 additions and 0 deletions
+88
View File
@@ -0,0 +1,88 @@
---
apiVersion: v1
kind: Service
metadata:
name: db
namespace: epcare
spec:
selector:
app: db
ports:
- name: mysql
protocol: TCP
port: 3306
targetPort: 3306
clusterIP: None # Headless — stable DNS for OpenMRS without load balancing
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: db
namespace: epcare
spec:
replicas: 1
selector:
matchLabels:
app: db
template:
metadata:
labels:
app: db
spec:
nodeSelector:
kubernetes.io/hostname: NODE_HOSTNAME
# Fix: chown /var/lib/mysql to mysql user (999) at pod start
securityContext:
fsGroup: 999
initContainers:
- name: fix-permissions
image: busybox
command: ["sh", "-c", "chown -R 999:999 /var/lib/mysql"]
volumeMounts:
- name: db-data
mountPath: /var/lib/mysql
imagePullSecrets:
- name: gitlab-registry
containers:
- name: db
image: registry.gitlab.com/signalytic/client-external/epcare/mysql/arm64:1.0
imagePullPolicy: IfNotPresent
args:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
envFrom:
- secretRef:
name: db-env
ports:
- containerPort: 3306
readinessProbe:
exec:
command:
- sh
- -c
- 'mysqladmin ping -h localhost -u${MYSQL_USER} -p${MYSQL_PASSWORD}'
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 20
volumeMounts:
- name: db-data
mountPath: /var/lib/mysql
- name: mysql-config
mountPath: /etc/mysql/conf.d/mysql.cnf
subPath: mysql.cnf
readOnly: true
- name: db-dumps
mountPath: /docker-entrypoint-initdb.d
readOnly: true
volumes:
- name: db-data
persistentVolumeClaim:
claimName: db-data-pvc
- name: mysql-config
configMap:
name: mysql-config
- name: db-dumps
hostPath:
path: /opt/epcare/resources/db/dumps
type: DirectoryOrCreate