gitea

by jfelten

Helm chartv0.2.10App 1.12.4MIT

Git with a cup of tea

About this chart

Gitea Helm chart

Gitea is a lightweight GitHub clone. This is for those who wish to self host their own git repos on kubernetes.

Introduction

This is a kubernetes helm chart for Gitea. It deploys a pod containing containers for the Gitea application along with a Postgresql db for storing application state. It can create peristent volume claims if desired, and also an ingress if the kubernetes cluster supports it.

This chart should work works on current supported versions of kubernetes. It is always in active use on the latest kubernetes and sync'd to the latest gitea release to stay current.

Currently the chart supports helm 3 only.

Prerequisites

  • A kubernetes cluster ( most recent release recommended)
  • helm client and tiller installed on the cluster
  • Please ensure that nodepools have enough resources to run both a web application and database
  • An external database if not using the in pod database

Installing the Chart

This chart is published in keyporttech/charts. To install the chart, first add the keyporttech helm repo:

helm repo add keyporttech https://keyporttech.github.io/helm-charts/

Then to install with the release name gitea in the namespace gittea with the customized values in custom_values.yaml run:

$ helm install -- values custom_values.yaml --name gitea --namespace gitea keyporttech/gitea

or locally:

$ helm install --name gitea --namewspace tools .

Tip: You can use the default values.yaml

Contributing

Please see keyporttech charts contribution guidelines

Running the cicd tooling locally

This chart uses a Makefile to run CICD. To run:

make build

Database config in pod vs external db

By default the chart will spin up a postgres container inside the pod. It can also work with external databases. To disable the in pod database and use and external one use the following values:

dbType: "postgres"
useInPodPostgres: false

#Connect to an external database
externalDB:
   dbUser: "postgres"
   dbPassword: "<MY_PASSWORD>"
   dbHost: "db-service-name.namespace.svc.cluster.local" # or some external host
   dbPort: 5432
   dbDatabase: "gitea"

This chart has only been tested using a postgres database. It is theoretically possible to work with others that gitea supports, but no testing has been done. Pull Requests to support or confirmation of other database connectivity would be much appreciated.

Example custom_values.yaml configs

This configuration creates pvcs with the storageclass glusterfs that cannot be deleted by helm, a kubernetes nginx ingress that serves the web applcation on external dns name git.example.com:8880 and exposes ssh through a NodePort that is exposed externally on a router using port 8022. The external DNS name for ssh is git.example.com.

ingress:
  enabled: true
  useSSL: false
  ## annotations used by the ingress - ex for k8s nginx ingress controller:
  ingress_annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
    nginx.ingress.kubernetes.io/auth-secret: basic-auth
    nginx.ingress.kubernetes.io/auth-realm: "Authentication Required - lab2"

service:
  http:
    serviceType: ClusterIP
    port: 3000
    externalPort: 8280
    externalHost: git.example.com
  ssh:
    serviceType: NodePort
    port: 22
    nodePort: 30222
    externalPort: 8022
    externalHost: git.example.com

persistence:
  enabled: true
  giteaSize: 10Gi
  postgresSize: 5Gi
  storageClass: glusterfs
  accessMode: ReadWriteMany
  annotations:
    "helm.sh/resource-policy": keep

Uninstalling the Chart

To uninstall/delete the gitea deployment:

$ helm uninstall gitea --namespace gitea

The command removes all the Kubernetes components associated with the chart and deletes the release.

Data Management

This chart will use and create optional persistent volume claims for both postgres (if using in pod db) and gitea data. By default the data will be deleted upon uninstalling the chart. This is not ideal but can be managed in a couple ways:

  • prevent helm from deleting the pvcs it creates. Do this by enabling annotation: helm.sh/resource-policy": keep in the pvc optional annotations
persistence:
  annotations:
    "helm.sh/resource-policy": keep
  • create a pvc outside the chart and configure the chart to use it. Do this by setting the persistence existingGiteaClaim and existingPostgresClaim properties.
 existingGiteaClaim: gitea-gitea
 existingPostgresClaim: gitea-postgres

a trick that can be is used to first set the helm.sh/resource-policy annotation so that the chart generates the pvcs, but doesn't delete them. Upon next deplyment set the exsiting claim names to the generated values.

Ingress And External Host/Ports

Gitea requires ports to be exposed for both web and ssh traffic. The chart is flexible and allow a combination of either ingresses, loadblancer, or nodeport services.

To expose the web application this chart will generate an ingress using the ingress controller of choice if specified. If an ingress is enabled services.http.externalHost must be specified. To expose SSH services it relies on either a LoadBalancer or NodePort.

Configuration

Refer to values.yaml for the full run-down on defaults.

The following table lists the configurable parameters of this chart and their default values.

ParameterDescriptionDefault
images.giteagitea imagegitea/gitea:1.12.4
images.postgrespostgres imagepostgres:9.6
images.imagePullPolicyImage pull policyAlways if imageTag is latest, else IfNotPresent
images.imagePullSecretsImage pull secretsnil
ingress.enabledSwitch to create ingress for this chart deploymentfalse
ingress.useSSLChanges default protocol to SSL?false
ingress.ingress_annotationsannotations used by the ingressnil
service.http.serviceTypetype of kubernetes services used for http i.e. ClusterIP, NodePort or LoadBalancerClusterIP
service.http.porthttp port for web traffic3000
service.http.NodePortManual NodePort for web trafficnil
service.http.externalPortPort exposed on the internet by a load balancer or firewall that redirects to the ingress or NodePortnil
service.http.externalHostIP or DNS name exposed on the internet by a load balancer or firewall that redirects to the ingress or Node for http trafficnil
service.http.loadBalancerIPIf the service is a LoadBalancer you can pre-allocate its IP address hereunset
service.http.svc_annotationsSet annotations for the http svc object.[]
service.ssh.serviceTypetype of kubernetes services used for ssh i.e. ClusterIP, NodePort or LoadBalancerClusterIP
service.ssh.porthttp port for web traffic22
service.ssh.NodePortManual NodePort for ssh trafficnil
service.ssh.externalPortPort exposed on the internet by a load balancer or firewall that redirects to the ingress or NodePortnil
service.ssh.externalHostIP or DNS name exposed on the internet by a load balancer or firewall that redirects to the ingress or Node for http traffic
service.ssh.loadBalancerIPIf the service is a LoadBalancer you can pre-allocate its IP address hereunset
service.ssh.svc_annotationsSet annotations for the ssh svc object. E.g. needed when using a load balancer and it should be a private load balancer instead of public.[]
resources.gitea.requests.memorygitea container memory request100Mi
resources.gitea.requests.cpugitea container request cpu500m
resources.gitea.limits.memorygitea container memory limits2Gi
resources.gitea.limits.cpugitea container CPU/Memory resource requests/limitsMemory: 1
resources.postgres.requests.memorypostgres container memory request256Mi
resources.postgres.requests.cpugitea container request cpu100m
persistence.enabledCreate PVCs to store gitea and postgres data?false
persistence.existingGiteaClaimAlready existing PVC that should be used for gitea data.nil
persistence.existingPostgresClaimAlready existing PVC that should be used for postgres data.[]
persistence.giteaSizeSize of gitea pvc to create10Gi
persistence.postgresSizeSize of postgres pvc to create5Gi
persistence.storageClassNStorageClass to use for dynamic provision if not 'default'nil
persistence.annotationsAnnotations to set on created PVCsnil
dbTypetype of database storage "postgres"
useInPodPostgrescreate a postgres pos for db storage -must use externalDB if false true
externalDB.dbUserexternal db user unset
externalDB.dbPasswordexternal db password unset
externalDB.dbHostexternal db host unset
externalDB.dbPortexternal db port - integer value (ex: 5432) unset
externalDB.dbDatabaseexternal db database name unset
inPodPostgres.secretGenerated Secret to store postgres passwordspostgressecrets
inPodPostgres.subPathSubpath for Postgres data storagenil
inPodPostgres.dataMountPathPath for Postgres data storagenil
affinityAffinity settings for pod assignment{}
tolerationsToleration labels for pod assignment[]
config.offlineModeSets Gitea's Offline Mode. Values are true or false.false
config.disableRegistrationDisable Gitea's user registration. Values are true or false.false
config.requireSigninRequire Gitea user to be signed in to see any pages. Values are true or false.false
config.openidSigninAllow login with OpenID. Values are true or false.true
`config.notify

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 v0.2.10 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