From 3525387799e31b3bd43930f81f37917f2339c178 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Mon, 11 Nov 2024 13:45:31 +0100 Subject: [PATCH] feat: Upgrade configuration for production --- README.md | 44 +++++++++++++++++++++++++++++++++++++++ manifests/configmap.yaml | 6 ++++-- manifests/database.yaml | 2 +- manifests/deployment.yaml | 8 ++----- manifests/ingress.yaml | 2 +- manifests/pvc.yaml | 6 +++--- manifests/secrets.yaml | 4 ++-- 7 files changed, 57 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 01b84be..8a2b683 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,47 @@ Front end for Git, with integrated Container Registry and CI/CD capabilities. This repository only contains configuration used for Kubernetes. +## From Docker to Gitea + +Get a dump of your current Docker instance: +```bash +gitea dump -c /data/gitea/conf/app.ini +``` +In this context, my `/data` path is mounted to the host. + +Then modify the `deployment.yaml` file to only start a "sleeping" container: +```yaml +[...] +image: gitea/gitea:1.22.3 +ports: + - containerPort: 3000 +command: ["/bin/sh", "-c", "sleep 1000000000"] # Add this line +env: + - name: GITEA__database__DB_TYPE + value: "postgres" +[...] +``` + +Then, copy the dump to the container: +```bash +kubectl cp /:/data/dump +``` + +Get into the pod and go as follows. + +Unzip the dump +```bash +unzip +``` + +Then, restore the dump +```bash +mv repo/* /data/git/repositories +mv lfs/* /data/git/lfs +mv data/* /data/gitea +``` + +And finally, restore the database +```bash +PGPASSWORD=$GITEA__database_PASSWD psql -h $GITEA__database_HOST -U $GITEA__database_USER < gitea-db.sql +``` diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 89d7c4c..40e3cfd 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -4,13 +4,15 @@ metadata: name: gitea-config namespace: gitea data: - APP_NAME: Halia hosted git solution + APP_NAME: Halis hosted git solution RUN_MODE: prod GITEA__server__DISABLE_SSH: "true" - GITEA__server__ROOT_URL: "https://git.beta.halia.dev" + GITEA__server__ROOT_URL: "https://git.halis.io" GITEA__security__INSTALL_LOCK: "true" GITEA__service__DISABLE_REGISTRATION: "true" GITEA__metrics__ENABLED: "true" + GITEA__queue__TYPE: "level" + #GITEA__indexer__REPO_INDEXER_ENABLED: "false" #app.ini: | # APP_NAME = K8s implementation # RUN_MODE = prod diff --git a/manifests/database.yaml b/manifests/database.yaml index b128be6..b498506 100644 --- a/manifests/database.yaml +++ b/manifests/database.yaml @@ -9,7 +9,7 @@ spec: storage: size: 1Gi - storageClass: flat-storage-class + storageClass: redundant-storage-class bootstrap: initdb: diff --git a/manifests/deployment.yaml b/manifests/deployment.yaml index a74c154..5620949 100644 --- a/manifests/deployment.yaml +++ b/manifests/deployment.yaml @@ -4,7 +4,7 @@ metadata: name: gitea namespace: gitea spec: - replicas: 2 + replicas: 1 selector: matchLabels: app: gitea @@ -17,13 +17,9 @@ spec: subdomain: gitea containers: - name: gitea - image: gitea/gitea:1.19.3 + image: gitea/gitea:1.22.3 ports: - containerPort: 3000 - lifecycle: - postStart: - exec: - command: ["sh", "-c", "sleep 1 && su git -c 'sh /admin-creator.sh'"] env: - name: GITEA__database__DB_TYPE value: "postgres" diff --git a/manifests/ingress.yaml b/manifests/ingress.yaml index de8c5ba..6d9d05b 100644 --- a/manifests/ingress.yaml +++ b/manifests/ingress.yaml @@ -20,7 +20,7 @@ spec: entryPoints: - websecure routes: - - match: Host(`git.beta.halia.dev`) && PathPrefix(`/`) + - match: Host(`git.halis.io`) && PathPrefix(`/`) kind: Rule middlewares: - name: replace-regex diff --git a/manifests/pvc.yaml b/manifests/pvc.yaml index a7f9ed3..ba37892 100644 --- a/manifests/pvc.yaml +++ b/manifests/pvc.yaml @@ -5,8 +5,8 @@ metadata: namespace: gitea spec: accessModes: - - ReadWriteOnce + - ReadWriteMany resources: requests: - storage: 5Gi - storageClassName: flat-storage-class + storage: 15Gi + storageClassName: redundant-storage-class diff --git a/manifests/secrets.yaml b/manifests/secrets.yaml index 65a1bac..abed56f 100644 --- a/manifests/secrets.yaml +++ b/manifests/secrets.yaml @@ -8,8 +8,8 @@ metadata: spec: project: default source: - repoURL: https://git.halis.io/athens-school/k3s-secrets.git - targetRevision: dev + repoURL: https://git.halia.dev/athens-school/k3s-secrets.git + targetRevision: prod-migration path: gitea syncPolicy: automated: