
kubectl cnpg psql pg-devops -n devops

CREATE DATABASE giteadb;
CREATE USER gitea WITH PASSWORD 'KAYQE1QA7uwUZ8uI';
GRANT ALL PRIVILEGES ON DATABASE giteadb TO gitea;
ALTER DATABASE giteadb OWNER TO gitea;

helm repo add gitea https://dl.gitea.io/charts/
helm repo update


kubectl create namespace gitea

cat <<EOF |cat >values.yaml -
replicaCount: 1

image:
  repository: gitea/gitea
  tag: 1.22.0
  pullPolicy: IfNotPresent

strategy:
  type: Recreate

service:
  http:
    type: ClusterIP
    port: 3000
  ssh:
    type: ClusterIP
    port: 22

redis-cluster:
  enabled: false

redis:
  enabled: false
  
ingress:
  enabled: false

persistence:
  enabled: true
  storageClass: csi-rbdfs-sc
  size: 10Gi

postgresql:
  enabled: false

postgresql-ha:
  enabled: false
  
gitea:
  admin:
    username: gitadmin
    password: KAYQE1QA7uwUZ8uI
    email: gitadmin@italiadatacenter.com

  config:
    database:
      DB_TYPE: postgres
      HOST: pg-devops-rw.devops.svc:5432
      NAME: giteadb
      USER: gitea
      PASSWD: KAYQE1QA7uwUZ8uI
      SSL_MODE: disable

    server:
      ROOT_URL: https://git.italiadatacenter.com/
      SSH_DOMAIN: git.italiadatacenter.com
      SSH_PORT: 22

    security:
      INSTALL_LOCK: true

EOF

helm upgrade --install gitea gitea-charts/gitea  --namespace gitea -f values.yaml


apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: gitea
  namespace: gitea
spec:
  hostnames:
  - git.italiadatacenter.com
  parentRefs:
  - name: main-gateway
    namespace: nginx-gateway
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - name: gitea-http
      port: 3000
