forgejo
by Forgejo
Forgejo Helm chart for Kubernetes
About this chart
Forgejo Helm Chart
- Introduction
- Update and versioning policy
- Dependencies
- Installing
- High Availability
- Configuration
- Default Configuration
- Database defaults
- Server defaults
- Metrics defaults
- Rootless Defaults
- Session, Cache and Queue
- Single-Pod Configurations
- Additional app.ini settings
- User defined environment variables in app.ini
- External Database
- Ports and external url
- SSH and Ingress
- SSH on crio based kubernetes cluster
- Cache
- Persistence
- Admin User
- LDAP Settings
- OAuth2 Settings
- Default Configuration
- Configure commit signing
- Metrics and profiling
- Pod annotations
- Themes
- Using Renovate
- Parameters
- Global
- strategy
- Image
- Security
- Service
- Ingress
- deployment
- ServiceAccount
- Persistence
- Init
- Signing
- Gitea
app.inioverrides- LivenessProbe
- ReadinessProbe
- StartupProbe
- Advanced
- Contributing
- Upgrading
- To v17
- To v16
- To v15
- To v14
- To v13
- To v12
- To v11
- To v10
- To v9
- To v8
- To v7
- To v6
Forgejo is a community managed lightweight code hosting solution written in Go. It is published under the MIT license.
Introduction
This Helm chart is based on the Gitea chart. Yet it takes a completely different approach in providing a database and cache with dependencies. Additionally, this chart allows to provide LDAP and admin user configuration with values.
Update and versioning policy
The Forgejo helm chart versioning does not follow Forgejo's versioning. The latest chart version can be looked up in https://code.forgejo.org/forgejo-helm/-/packages/container/forgejo or in the repository releases.
The chart aims to follow Forgejo's releases closely.
There might be times when the chart is behind the latest Forgejo release.
This might be caused by different reasons, most often due to time constraints of the maintainers (remember, all work here is done voluntarily in the spare time of people).
If you're eager to use the latest Forgejo version earlier than this chart catches up, then change the tag in values.yaml to the latest Forgejo version.
Dependencies
Forgejo can be run with an external database and cache.
Installing
helm install forgejo oci://code.forgejo.org/forgejo-helm/forgejo
In case you want to supply values, you can reference a values.yaml file:
helm install forgejo -f values.yaml oci://code.forgejo.org/forgejo-helm/forgejo
When upgrading, please refer to the Upgrading section at the bottom of this document for major and breaking changes.
High Availability
See the HA Setup document for more details.
Configuration
Forgejo offers lots of configuration options. Every value described in the Cheat Sheet can be set as a Helm value. Configuration sections map to (lowercased) YAML blocks, while the keys themselves remain in all caps.
gitea:
config:
# values in the DEFAULT section
# (https://forgejo.org/docs/latest/admin/config-cheat-sheet/#overall-default)
# are un-namespaced
#
APP_NAME: 'Forgejo: Git with a cup of tea'
#
# https://forgejo.org/docs/latest/admin/config-cheat-sheet/#repository-repository
repository:
ROOT: '~/forgejo-repositories'
#
# https://forgejo.org/docs/latest/admin/config-cheat-sheet/#repository---pull-request-repositorypull-request
repository.pull-request:
WORK_IN_PROGRESS_PREFIXES: 'WIP:,[WIP]:'
Default Configuration
This chart will set a few defaults in the Forgejo configuration based on the service and ingress settings.
All defaults can be overwritten in gitea.config.
INSTALL_LOCK is always set to true because the configuration in this helm chart makes any configuration via installer superfluous.
All default settings are made directly in the generated app.ini, not in the Values.
Database defaults
This chart uses the default SQLite database.
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
ENABLE_PPROF = false
Metrics defaults
The Prometheus /metrics endpoint is disabled by default.
[metrics]
ENABLED = false
Rootless Defaults
If .Values.image.rootless: true, then the following will occur. In case you use .Values.image.fullOverride, check that this works in your image:
-
$HOMEbecomes/data/gitea/gitsee deployment.yaml template inside (init-)container "env" declarations
-
START_SSH_SERVER: true(Unless explicitly overwritten bygitea.config.server.START_SSH_SERVER)see _helpers.tpl in
gitea.inline_configuration.defaults.serverdefinition -
SSH_LISTEN_PORT: 2222(Unless explicitly overwritten bygitea.config.server.SSH_LISTEN_PORT)see _helpers.tpl in
gitea.inline_configuration.defaults.serverdefinition -
SSH_LOG_LEVELenvironment variable is not injected into the containersee deployment.yaml template inside container "env" declarations
Session, Cache and Queue
The chart will fall back to the Forgejo defaults which use "memory" for session and cache and "level" for queue.
While these will work and even not cause immediate issues after startup, they are not recommended for production use.
Reasons being that a single pod will take on all the work for session and cache tasks in its available memory.
It is likely that the pod will run out of memory or will face substantial memory spikes, depending on the workload.
External tools such as valkey-cluster or memcached handle these workloads much better.
Single-Pod Configurations
If HA is not needed/desired, the following configurations can be used to deploy a single-pod Forgejo instance.
For a production-ready single-pod Forgejo instance without external dependencies (using the built-in SQLite):
persistence:
enabled: true
gitea:
config:
indexer:
REPO_INDEXER_ENABLED: true
Additional app.ini settings
The generic section cannot be defined that way.
Some settings inside app.ini (like passwords or whole authentication configurations) must be considered sensitive and therefore should not be passed via plain text inside the values.yaml file. In times of GitOps the values.yaml could be stored in a Git repository where sensitive data should never be accessible.
The Helm Chart supports this approach and let the user define custom sources like Kubernetes Secrets to be loaded as environment variables during app.ini creation or update.
gitea:
additionalConfigSources:
- secret:
secretName: forgejo-app-ini-oauth
- configMap:
name: forgejo-app-ini-plaintext
This would mount the two additional volumes (oauth and some-additionals) from different sources to the init container where the app.ini gets updated.
All files mounted that way will be read and converted to environment variables and then added to the app.ini using environment-to-ini.
The key of such additional source represents the section inside the app.ini. The value for each key can be multiline ini-like definitions.
In example, the referenced forgejo-app-ini-plaintext could look like this.
apiVersion: v1
kind: ConfigMap
metadata:
name: forgejo-app-ini-plaintext
data:
session: |
PROVIDER=memory
SAME_SITE=strict
cron.archive_cleanup: |
ENABLED=true
Or when using a Kubernetes secret, having the same data structure:
apiVersion: v1
kind: Secret
metadata:
name: forgejo-security-related-configuration
type: Opaque
stringData:
security: |
PASSWORD_COMPLEXITY=off
session: |
SAME_SITE=strict
User defined environment variables in app.ini
Users are able to define their own environment variables, which are loaded into the containers. We also support interacting directly with the generated app.ini.
To inject self defined variables into the app.ini a certain format needs to be honored. This is described in detail on the env-to-ini page.
Environment variables need to be prefixed with FORGEJO.
For example a database setting needs to have the following format:
gitea:
config:
database:
HOST: my.own.host
additionalConfigFromEnvs:
- name: FORGEJO__DATABASE__PASSWD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
Priority (highest to lowest) for defining app.ini variables:
-
Environment variables prefixed with
FORGEJO -
Additional config sources
-
Values defined in
gitea.config
External Database
A supported external database can be used instead of the built-in SQLite. We recommend to use a PostgreSQL or MySQL database if you are planning a longterm use with 5+ active users and more than a few dozen repos.
Best practice is to use an Operator for database deployments, as this approach has many advantages for DB management in k8s compared to a standalone static one.
For Postgres, we can recommend the following ones:
For MySQL:
The following values settings must be used to reference an external DB:
gitea:
config:
database:
DB_TYPE: <dbtype> # supported values are mysql, postgres, mssql, sqlite3
HOST: <host>
NAME: <name>
USER: <user>
PASSWD: <passwd>
SCHEMA: <schema> # optional
Usually you do not want to pass the credentials directly in the values file. Instead, these can be referenced from a secret via
gitea:
additionalConfigSources:
- secret:
secretName: database
Note that when using this option, all DB options must be set in the secret.
External Redis/Valkey
[!TIP] For most use cases, the included adapters are fine. We only recommend this for medium-large instances. You can also start with the default ones and migrate at some point via a simple switchover - no data migration is necessary.
Instead of relying on the default adapters for cache & session, external Redis/Valkey instances can be used.
[!NOTE] The name adapter 'redis' is hardcoded from within Forgejo and works just fine with a Valkey instance.
gitea:
queue:
TYPE: redis
CONN_STR: redis://<url>:<port>/0?
cache:
ADAPTER: redis
HOST: redis://<url>:<port>/1
session:
PROVIDER: redis
PROVIDER_CONFIG: redis://<url>:<port>/2
Examples for the sentiel and cluster variants:
gitea:
queue:
TYPE: redis
CONN_STR: redis+sentinel://<url>:<port>/0?mastername=<mastername>
cache:
ADAPTER: redis
HOST: redis+sentinel://<url>:<port>/1?mastername=<mastername>
session:
PROVIDER: redis
PROVIDER_CONFIG: redis+sentinel://<url>:<port>/2?mastername=<mastername>
[!NOTE] The cluster variant can only use DB '0'
gitea:
queue:
TYPE: redis
CONN_STR: redis+cluster://<url>:<port>/0
cache:
ADAPTER: redis
HOST: redis+cluster://<url>:<port>/0
session:
PROVIDER: redis
PROVIDER_CONFIG: redis+cluster://<url>:<port>/0
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 helm chart 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 want 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 y
Deploy forgejo with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has forgejo 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartforgejo is pinned at v17.3.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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