feat(db): Migrate to CloudNativePG

This commit is contained in:
Tanguy Herbron 2024-01-14 00:09:47 +01:00
parent 1830d126a5
commit 39b680f3cf
5 changed files with 42 additions and 25 deletions

View File

@ -7,6 +7,7 @@ data:
APP_NAME: Halia hosted git solution APP_NAME: Halia hosted git solution
RUN_MODE: prod RUN_MODE: prod
GITEA__server__DISABLE_SSH: "true" GITEA__server__DISABLE_SSH: "true"
GITEA__server__ROOT_URL: "https://git.beta.halia.dev"
GITEA__security__INSTALL_LOCK: "true" GITEA__security__INSTALL_LOCK: "true"
GITEA__service__DISABLE_REGISTRATION: "true" GITEA__service__DISABLE_REGISTRATION: "true"
GITEA__metrics__ENABLED: "true" GITEA__metrics__ENABLED: "true"

View File

@ -1,26 +1,27 @@
kind: "postgresql" apiVersion: postgresql.cnpg.io/v1
apiVersion: "acid.zalan.do/v1" kind: Cluster
metadata: metadata:
name: "gitea" name: gitea-db
namespace: "gitea" namespace: gitea
labels:
team: acid
spec: spec:
teamId: "acid" instances: 1
storage:
size: 1Gi
storageClass: flat-storage-class
bootstrap:
initdb:
database: gitea
owner: gitea
secret:
name: gitea-db
postgresql: postgresql:
version: "15" pg_hba:
numberOfInstances: 1 - host all all all md5
volume:
size: "1Gi"
storageClass: "flat-storage-class"
users:
gitea: []
databases:
gitea: gitea
allowedSourceRanges:
# IP ranges to access your cluster go here
resources: resources:
requests: requests:
cpu: 100m cpu: 100m

View File

@ -29,7 +29,7 @@ spec:
- name: GITEA__database__DB_TYPE - name: GITEA__database__DB_TYPE
value: "postgres" value: "postgres"
- name: GITEA__database__HOST - name: GITEA__database__HOST
value: "gitea.gitea.svc.cluster.local:5432" value: "gitea-db-rw.gitea.svc.cluster.local:5432"
- name: GITEA__database__NAME - name: GITEA__database__NAME
value: "gitea" value: "gitea"
- name: GITEA__database__SSL_MODE - name: GITEA__database__SSL_MODE
@ -37,12 +37,12 @@ spec:
- name: GITEA__database__USER - name: GITEA__database__USER
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: gitea.gitea.credentials.postgresql.acid.zalan.do name: gitea-db
key: username key: username
- name: GITEA__database__PASSWD - name: GITEA__database__PASSWD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
name: gitea.gitea.credentials.postgresql.acid.zalan.do name: gitea-db
key: password key: password
- name: GITEA__server__LFS_JWT_SECRET - name: GITEA__server__LFS_JWT_SECRET
valueFrom: valueFrom:
@ -76,10 +76,12 @@ spec:
- mountPath: "/admin-creator.sh" - mountPath: "/admin-creator.sh"
name: gitea-admin-creator name: gitea-admin-creator
subPath: admin-creator.sh subPath: admin-creator.sh
- mountPath: "/data"
name: gitea-data
volumes: volumes:
- name: gitea-pv - name: gitea-data
hostPath: persistentVolumeClaim:
path: "/mnt/gitea" claimName: gitea-pvc
- name: gitea-config-volume - name: gitea-config-volume
configMap: configMap:
name: gitea-config name: gitea-config

View File

@ -9,4 +9,5 @@ resources:
- ingress.yaml - ingress.yaml
- configmap.yaml - configmap.yaml
- admin-creator.yaml - admin-creator.yaml
- pvc.yaml
- deployment.yaml - deployment.yaml

12
manifests/pvc.yaml Normal file
View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitea-pvc
namespace: gitea
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: flat-storage-class