feat(networking): Deploy gitea on primary node to allow faster traffic

This commit is contained in:
Tanguy Herbron 2025-04-29 17:24:03 +02:00
parent 1ea885f030
commit f74fc704b6
4 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
labels:
cnpg.io/cluster: gitea-db
name: gitea-db-local
namespace: gitea
spec:
internalTrafficPolicy: Local
ports:
- name: postgres
port: 5432
protocol: TCP
targetPort: 5432
selector:
cnpg.io/cluster: gitea-db
cnpg.io/instanceRole: primary

View File

@ -51,3 +51,11 @@ spec:
monitoring:
enablePodMonitor: true
topologySpreadConstraints:
- maxSkew: 1
topologyKey: zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
cnpg.io/cluster: gitea-db

View File

@ -15,6 +15,20 @@ spec:
spec:
hostname: gitea
subdomain: gitea
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: cnpg.io/cluster
operator: In
values:
- gitea-db
- key: cnpg.io/instanceRole
operator: In
values:
- primary
topologyKey: "kubernetes.io/hostname"
containers:
- name: gitea
image: gitea/gitea:1.23.7
@ -24,7 +38,7 @@ spec:
- name: GITEA__database__DB_TYPE
value: "postgres"
- name: GITEA__database__HOST
value: "gitea-db-rw.gitea.svc.cluster.local:5432"
value: "gitea-db-local.gitea.svc.cluster.local:5432"
- name: GITEA__database__NAME
value: "gitea"
- name: GITEA__database__SSL_MODE

View File

@ -5,6 +5,7 @@ resources:
- namespace.yaml
- secrets.yaml
- database.yaml
- database-local-service.yaml
- database-backup.yaml
- service.yaml
- servicemonitor.yaml