gitea

by NOVUM-RGI

Helm chartv2.1.3App 1.13.0MIT

Gitea Helm chart for Kubernetes

About this chart

Gitea Helm Chart

Gitea is a community managed lightweight code hosting solution written in Go. It is published under the MIT license.

Introduction

This helm chart has taken some inspiration from https://github.com/jfelten/gitea-helm-chart But takes a completly different approach in providing database and cache with dependencies. Also this chart provides ldap and admin user configuration with values as well as it is deployed as statefulset to retain stored repositories.

Dependencies

Gitea can be run with external database and cache. This chart provides those dependencies, which can be enabled, or disabled via configuration.

Dependencies:

  • Postgresql
  • Memcached
  • Mysql

Installing

  helm repo add gitea-charts https://dl.gitea.io/charts/
  helm install gitea gitea-charts/gitea

Prerequisites

  • Kubernetes 1.12+
  • Helm 3.0+
  • PV provisioner for persistent data support

Examples

Gitea Configuration

Gitea offers lots of configuration. This is fully described in the Gitea Cheat Sheet.

  gitea:
    config:
      APP_NAME: "Gitea: With a cup of tea."
      repository:
        ROOT: "~/gitea-repositories"
      repository.pull-request:
        WORK_IN_PROGRESS_PREFIXES: "WIP:,[WIP]:"

Default Configuration

This chart will set a few defaults in the gitea configuration based on the service and ingress settings. All defaults can be overwritten in gitea.config.

INSTALL_LOCK is always set to true, since we want to configure gitea with this helm chart and everything is taken care of.

All default settings are made directly in the generated app.ini, not in the Values.

Database defaults

If a builtIn database is enabled the database configuration is set automatically. For example postgresql builtIn which will appear in the app.ini as:

[database]
DB_TYPE = postgres
HOST = RELEASE-NAME-postgresql.default.svc.cluster.local:5432
NAME = gitea
PASSWD = gitea
USER = gitea

Memcached defaults

Memcached is handled the exakt same way as database builtIn. Once memcached builtIn is enabled, this chart will generate the following part in the app.ini:

[cache]
ADAPTER = memcache
ENABLED = true
HOST = RELEASE-NAME-memcached.default.svc.cluster.local:11211

Server defaults

The server defaults are a bit more complex. If ingress is enabled, the ROOT_URL, DOMAIN and SSH_DOMAIN will be set accordingly. HTTP_PORT always defaults to 3000 as well as SSH_PORT to 22.

[server]
APP_DATA_PATH = /data
DOMAIN = git.example.com
HTTP_PORT = 3000
PROTOCOL = http
ROOT_URL = http://git.example.com
SSH_DOMAIN = git.example.com
SSH_LISTEN_PORT = 22
SSH_PORT = 22

External Database

An external Database can be used instead of builtIn postgresql or mysql.

  gitea:
    database:
      builtIn:
        postgresql:
          enabled: false

    config:
      database:
        DB_TYPE: mysql
        HOST: 127.0.0.1:3306
        NAME: gitea
        USER: root
        PASSWD: gitea
        SCHEMA: gitea

Ports and external url

By default port 3000 is used for web traffic and 22 for ssh. Those can be changed:

  service:
    http: 
      port: 3000
    ssh:
      port: 22

This helmchart automatically configures the clone urls to use the correct ports. You can change these ports by hand using the gitea.config dict. However you should know what you're doing.

SSH and Ingress

If you're using ingress and wan't to use SSH, keep in mind, that ingress is not able to forward SSH Ports. You will need a LoadBalancer like metallb and a setting in your ssh service annotations.

service:
  ssh:
    annotations:
      metallb.universe.tf/allow-shared-ip: test

Cache

This helm chart can use a built in cache. The default is memcached from bitnami.

  gitea:
    cache:
      builtIn:
        enabled: true

If the built in cache should not be used simply configure the cache in gitea.config

  gitea:
    config:
      cache:
        ENABLED: true
        ADAPTER: memory
        INTERVAL: 60
        HOST: 127.0.0.1:9090

Persistence

Gitea will be deployed as a statefulset. By simply enabling the persistence and setting the storage class according to your cluster everything else will be taken care of. The following example will create a PVC as a part of the statefulset. This PVC will not be deleted even if you uninstall the chart. When using Postgresql as dependency, this will also be deployed as a statefulset by default.

If you want to manage your own PVC you can simply pass the PVC name to the chart.

  persistence:
    enabled: true
    existingClaim: MyAwesomeGiteaClaim

In case that peristence has been disabled it will simply use an empty dir volume.

Postgresql handles the persistence in the exact same way. You can interact with the postgres settings as displayed in the following example:

  postgresql:
    persistence:
      enabled: true
      existingClaim: MyAwesomeGiteaPostgresClaim

Mysql also handles persistence the same, even though it is not deployed as a statefulset. You can interact with the postgres settings as displayed in the following example:

  mysql:
    persistence:
      enabled: true
      existingClaim: MyAwesomeGiteaMysqlClaim

Admin User

This chart enables you to create a default admin user. It is also possible to update the password for this user by upgrading or redeloying the chart. It is not possible to delete an admin user after it has been created. This has to be done in the ui.

  gitea:
    admin:
      username: "MyAwesomeGiteaAdmin"
      password: "AReallyAwesomeGiteaPassword"
      email: "[email protected]"

LDAP Settings

Like the admin user the ldap settings can be updated but also disabled or deleted. All ldap values from https://docs.gitea.io/en-us/command-line/#admin are available. You can either use them in camel case or kebab case.

camelCase:

  gitea:
    ldap:
      enabled: true
      name: 'MyAwesomeGiteaLdap'
      securityProtocol: unencrypted
      host: "127.0.0.1"
      port: "389"
      userSearchBase: ou=Users,dc=example,dc=com
      userFilter: sAMAccountName=%s
      adminFilter: CN=Admin,CN=Group,DC=example,DC=com
      emailAttribute: mail
      bindDn: CN=ldap read,OU=Spezial,DC=example,DC=com
      bindPassword: JustAnotherBindPw
      usernameAttribute: CN

Kebab-Case:

  gitea:
    ldap:
      enabled: true
      name: 'MyAwesomeGiteaLdap'
      security-protocol: unencrypted
      host: "127.0.0.1"
      port: "389"
      user-search-base: ou=Users,dc=example,dc=com
      user-filter: sAMAccountName=%s
      admin-filter: CN=Admin,CN=Group,DC=example,DC=com
      email-attribute: mail
      bind-dn: CN=ldap read,OU=Spezial,DC=example,DC=com
      bind-password: JustAnotherBindPw
      username-attribute: CN

Pod Annotations

Annotations can be added to the Gitea pod.

  gitea:
    podAnnotations: {}

Configuration

Others

ParameterDescriptionDefault
statefulset.terminationGracePeriodSecondsImage to start for this podgitea/gitea
statefulset.envAdditional environment variables to pass to containers[]

Image

ParameterDescriptionDefault
image.repositoryImage to start for this podgitea/gitea
image.versionImage Version1.13.0
image.pullPolicyImage pull policyAlways

Persistence

ParameterDescriptionDefault
persistence.enabledEnable persistence for Giteatrue
persistence.existingClaimUse an existing claim to store repository information
persistence.sizeSize for persistence to store repo information10Gi
persistence.accessModesAccessMode for persistence
persistence.storageClassStorage class for repository persistence

Ingress

ParameterDescriptionDefault
ingress.enabledenable ingressfalse
ingress.annotationsadd ingress annotations
ingress.hostsadd hosts for ingress as string listgit.example.com
ingress.tlsadd ingress tls settings[]

Service

ParameterDescriptionDefault
service.http.typeKubernetes service type for web trafficClusterIP
service.http.portPort for web traffic3000
service.ssh.typeKubernetes service type for ssh trafficClusterIP
service.ssh.portPort for ssh traffic22
service.ssh.externalTrafficPolicyIf service.ssh.type is NodePort or LoadBalancer, set this to Local to enable source IP preservation
service.ssh.externalIPsSSH service external IP addresses[]
service.ssh.annotationsAdditional ssh annotations for the ssh service

Gitea Configuration

ParameterDescriptionDefault
gitea.configEverything in app.ini can be configured with this dict. See Examples for more details{}

Memcached BuiltIn

Memcached is loaded as a dependency from Bitnami if enabled in the values. Complete Configuration can be taken from their website.

The following parameters are the defaults set by this chart

ParameterDescriptionDefault
memcached.service.portMemcached Port11211

Mysql BuiltIn

Mysql is loaded as a dependency from stable. Configuration can be found from this website

The following parameters are the defaults set by this chart

ParameterDescriptionDefault
mysql.mysqlRootPasswordPassword for the root user. Ignored if existing secret is providedgitea
mysql.mysqlUserUsername of new user to create.gitea
mysql.mysqlPasswordPassword for the new user. Ignored if existing secret is providedgitea
mysql.mysqlDatabaseName for new database to create.gitea
mysql.service.portPort to connect to mysql service3306
mysql.persistence.sizePersistence size for mysql10Gi

Postgresql BuiltIn

Postgresql is loaded as a dependency from bitnami. Configuration can be found from this Bitnami

The following parameters are the defaults set by this chart

ParameterDescriptionDefault
postgresql.global.postgresql.postgresqlDatabasePostgreSQL database (overrides postgresqlDatabase)gitea
postgresql.global.postgresql.postgresqlUsernamePostgreSQL username (overrides postgresqlUsername)gitea
postgresql.global.postgresql.postgresqlPasswordPostgreSQL admin password (overrides postgresqlPassword)gitea
postgresql.global.postgresql.servicePortPostgreSQL port (overrides service.port)5432
postgresql.persistence.sizePVC Storage Request for PostgreSQL volume10Gi

MariaDB BuiltIn

MariaDB is loaded as a dependency from bitnami. Configuration can be found from this Bitnami

The following parameters are the defaults set by this chart

ParameterDescriptionDefault
mariadb.auth.usernameUsername of new user to create.gitea
mariadb.auth.passwordPassword for the new user. Ignored if existing secret is providedgitea
mariadb.auth.databaseName for new database to create.gitea
mariadb.auth.rootPasswordPassword for the root user.gitea
mariadb.primary.service.portPort to connect to mariadb service3306
mariadb.primary.persistence.sizePersistence size for mariadb10Gi

Deploy gitea with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has gitea on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartgitea is pinned at v2.1.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply