Files
base-infra/roles/k8s-setup/tasks/_gitea.yml
Felix Nehrke 7ec64630a7 Switch from HA-Cluster to single-instance DB for gitea
Intially I had setup a high availability cluster for my gitea instance,
basically as an experiment. Though this experiement was doomed by my
effort to keep the required infrastructure small when ever possible. In
the end I struggled with constant downtimes due to memory limitations
and other sideeffects.

On the other hand I do _not_ need a highly available DB for my very
personal git-server. In the worst case I can still deconnect the whole
thing from the internet, restart it and investigate issues without
pressure.

Note though that even this little shift needed some preparation:

1. Forward the DB-port to the local machine
   `kubectl port-forward -n gitea service/gitea-postgresql-ha-pgpool 5432:5432`
2. Create valid backup of the DB
   `pg_dump --dbname=gitea --file=/app/Gitea-$(date +%Y_%m_%d_%H_%M_%S)-dump.sql -F c --host=localhost --port=5432`
3. Apply the new setup
   `ansible-playbook site.yml --tags=gitea`
4. Forward the DB-port to the local machine of the new DB
   `kubectl port-forward -n gitea service/gitea-postgresql 5432:5432`
5. Restore the DB cleanly (`-c`)
   `pg_restore -c --username=gitea --host=localhost --port=5432 -d gitea Gitea-*-dump.sql`
6. Reupload one of the SSH-Keys to restore the SSH-configuration on disk
   from DB.
2026-04-26 17:22:02 +02:00

137 lines
3.9 KiB
YAML

- name: Ensure gitea namespace
kubernetes.core.k8s:
state: "{{ gitea_state }}"
definition:
apiVersion: v1
kind: Namespace
metadata:
name: gitea
labels:
name: gitea
- name: Ensure gitea imagePullSecrets
kubernetes.core.k8s:
state: "{{ gitea_state }}"
definition:
apiVersion: v1
kind: Secret
metadata:
name: gitea-image-registry-secret
namespace: gitea
data:
.dockerconfigjson: "{{ gitea_image_registry_secret }}"
type: kubernetes.io/dockerconfigjson
- name: Ensure custom gitea-templates
kubernetes.core.k8s:
state: "{{ gitea_state }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: gitea-custom-templates
namespace: gitea
data:
header.tmpl: <link rel="stylesheet" href="{{ '{{' }}AppSubUrl{{ '}}' }}/assets/css/asciidoc.css" />
- name: Ensure custom gitea-styles
kubernetes.core.k8s:
state: "{{ gitea_state }}"
definition:
apiVersion: v1
kind: ConfigMap
metadata:
name: gitea-custom-styles
namespace: gitea
data:
asciidoc.css: "{{ lookup('file', 'asciidoc.css') }}"
- name: Deploy gitea {{ gitea_chart_version }}
kubernetes.core.helm:
name: gitea
chart_ref: oci://registry-1.docker.io/giteacharts/gitea
chart_version: "{{ gitea_chart_version }}"
release_namespace: "gitea"
release_state: "{{ gitea_state }}"
values:
imagePullSecrets:
- name: gitea-image-registry-secret
image:
registry: "{{ gitea_image_registry }}"
repository: "{{ gitea_image }}"
tag: "{{ gitea_image_tag }}"
rootless: "{{ gitea_image_rootless }}"
pullPolicy: "{{ gitea_image_pull_policy }}"
ui:
AMBIGUOUS_UNICODE_DETECTION: "false"
gitea:
admin:
username: "{{ gitea_admin_user }}"
password: "{{ gitea_admin_password }}"
email: "{{ gitea_admin_email }}"
config:
APP_NAME: "Gitea: Mein kleiner git-server"
service:
DISABLE_REGISTRATION: "true"
markup.plantuml:
ENABLED: "true"
NEED_POSTPROCESS: "false"
FILE_EXTENSIONS: .puml,.plantuml
RENDER_COMMAND: gitea-plantuml
IS_INPUT_FILE: "true"
RENDER_CONTENT_MODE: no-sanitizer
markup.asciidoc:
ENABLED: "true"
NEED_POSTPROCESS: "false"
FILE_EXTENSIONS: .adoc,.asciidoc
RENDER_COMMAND: gitea-asciidoc
IS_INPUT_FILE: "true"
RENDER_CONTENT_MODE: no-sanitizer
server:
# without this gravatar will not work!
OFFLINE_MODE: "false"
ingress:
enabled: True
annotations:
cert-manager.io/cluster-issuer: "{{ gitea_certificate_issuer }}"
traefik.ingress.kubernetes.io/router.middlewares: default-redirect-https@kubernetescrd
hosts:
- host: "{{ gitea_host }}"
tls:
- hosts:
- "{{ gitea_host }}"
secretName: gitea-tls
service:
ssh:
type: LoadBalancer
persistence:
size: 15Gi
postgresql:
enabled: True
primary:
persistence:
size: 2Gi
postgresql-ha:
enabled: False
persistence:
size: 2Gi
valkey:
enabled: True
valkey-cluster:
enabled: False
extraVolumes:
- name: gitea-custom-templates
configMap:
name: gitea-custom-templates
- name: gitea-custom-styles
configMap:
name: gitea-custom-styles
extraContainerVolumeMounts:
- name: gitea-custom-templates
readOnly: true
mountPath: /data/gitea/templates/custom
- name: gitea-custom-styles
readOnly: true
mountPath: /data/gitea/public/assets/css