Integrate NOVUM-RGI chart into the official helm chart. (#7)

Fix ssh port settings

Remove blank line from LICENSE file

add check for admin user

set PROTOCOL default to http

Add Konrad Lother as Maintainer

Update readme with generic values

make app.ini generic

- app.ini is now configurable via dictionary in values.yaml
- database and server configuration is autogenerated if not defined
- http and ssh services now use gitea config settings for targetPort
- add default security value INSTALL_LOCK = true
- clean up builtin cache settings

bump gitea version

Add values and Remove vscode TOC comments

- values enablePushCreateOrg and enablePushCreateUser have been added to repository settings

fix naming order of license and maintainers

Multiple improvements for the chart:

- add terminationGracePeriodSeconds to shutdown the statefulset gracefully on error
- add guard for loadbalancer settings in ssh service
- use mysql from bitnami, since they update the version much more frequent (old mysql only uses mysql ~6)
- init container now also provisions mysql and external database correctly

Fix PVC mounting issues for longhorn storageClass

Add examples to readme

Fix port setting for ssh

Fix and operator for newer helm versions

update values to support most configuration gitea offers

Replace Readme

update license file

Update helpers with dependencies, update NOTES.txt

update Chart.yaml with dependencies

Requirements.yaml removed, since this is deprecated and moved to Chart.yaml

Remove now unused dependencies and deployments

- init is no longer used since databases are initialized
  on original charts and managed with dependency
- ingress.yaml moved to templates/gitea
- deployment.yaml no longer used and replaced with templates/gitea/statefulset.yaml
- memcached also handled with helm dependency and initialized in original chart

Add initial test for gitea helm chart

Rework templates for helm chart.

- app.ini configurable via config
- admin user and ldap settings configurable via config
- using statefulset to handle pvc
- update helpers for new dependencies

remove helm build artifacts since they are not needed in this repository

Co-authored-by: Lucas Hahn <lucas.hahn@novum-rgi.de>
Co-authored-by: Konrad Lother <konrad.lother@novum-rgi.de>
Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/7
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
luhahn
2020-08-23 17:56:55 +00:00
committed by techknowlogick
parent b2725ae7cf
commit 5e0cfed9be
26 changed files with 805 additions and 1433 deletions

344
README.md
View File

@ -1,189 +1,249 @@
# Gitea
# Gitea Helm Chart
[Gitea](https://gitea.com/) is a lightweight GitHub clone. This is for those who wish to self host their own git repos on kubernetes.
[Gitea](https://gitea.io/en-us/) is a community managed lightweight code hosting solution written in Go. It is published under the MIT license.
This chart is based upon the work done by [@jfelten](https://github.com/jfelten/gitea-helm-chart)
## TLDR
```sh
helm repo add k8s-land https://charts.k8s.land
helm install gitea k8s-land/gitea
```
Readme will be updated with examples in the next few days
## Introduction
This chart bootstraps both [Gitea](http://gitea.com) and MariaDB.
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.
In this chart, the following are ran:
- Gitea
- Memcached
- Mariadb
## Dependencies
Gitea can be run with external database and cache. This chart provides those dependencies, which can be
enabled, or disabled via [configuration](#configuration).
Dependencies:
* Postgresql
* Memcached
* Mysql
## Installing
```
helm repo add novum-rgi-helm https://novumrgi.github.io/helm/
helm install gitea novum-rgi-helm/gitea
```
## Prerequisites
- Kubernetes 1.12+
- Helm 3.0+
- PV provisioner for persistent data support
* Kubernetes 1.12+
* Helm 3.0+
* PV provisioner for persistent data support
## Installing the Chart
## Examples
By default, we use ingress to expose the service.
### Gitea Configuration
To install WITHOUT persistent storage / development:
```bash
helm repo add k8s-land https://charts.k8s.land
helm install gitea k8s-land/gitea
```
For production / installing with persistent data:
```sh
helm show values k8s-land/gitea > values.yaml
vim values.yaml # Edit to enable persistent storage
helm install gitea k8s-land/gitea -f values.yaml
```
### Database Configuration
By default, we will launch a Mariadb database:
Gitea offers lots of configuration. This is fully described in the [Gitea Cheat Sheet](https://docs.gitea.io/en-us/config-cheat-sheet/).
```yaml
mariadb:
enabled: true
gitea:
config:
APP_NAME: "Gitea: With a cup of tea."
repository:
ROOT: "~/gitea-repositories"
repository.pull-request:
WORK_IN_PROGRESS_PREFIXES: "WIP:,[WIP]:"
```
To use an external database, disable the in-pod database and fill in the "externalDB" values:
### Ports and external url
By default port 3000 is used for web traffic and 22 for ssh. Those can be changed:
```yaml
mariadb:
enabled: 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"
service:
http:
port: 3000
ssh:
port: 22
```
## Persistent Data
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.
By default, persistent data is not enabled and thus you'll have to enable it from within the `values.yaml`.
### Cache
Unless otherwise set to true, data will be deleted when the Pod is restarted.
To prevent data loss, we will enable persistent data.
First, enable persistency:
This helm chart can use a built in cache. The default is memcached from bitnami.
```yaml
persistence:
enabled: true
gitea:
cache:
builtIn:
enabled: true
```
If you wish for helm **NOT** to replace data when re-deploying (updating the chart), add the `resource-policy` annotation:
If the built in cache should not be used simply configure the cache in gitea.config
```yaml
persistence:
annotations:
"helm.sh/resource-policy": keep
gitea:
config:
cache:
ENABLED: true
ADAPTER: memory
INTERVAL: 60
HOST: 127.0.0.1:9090
```
### Persistence
To use a previously created PVC / volume, use the following:
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.
```yaml
existingGiteaClaim: gitea-gitea
persistence:
enabled: true
existingClaim: MyAwesomeGiteaClaim
```
## Ingress And External Host/Ports
In case that peristence has been disabled it will simply use an empty dir volume.
Gitea requires ports to be exposed for accessibility. The recommended way is using **ingress**, however, you can supply `LoadBalancer` to your values alternatively.
By default, we expose via an ingress:
To expose via an ingress:
Postgresql handles the persistence in the exact same way.
You can interact with the postgres settings as displayed in the following example:
```yaml
ingress:
enabled: true
postgresql:
persistence:
enabled: true
existingClaim: MyAwesomeGiteaPostgresClaim
```
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.
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:
## Upgrading
```yaml
mysql:
persistence:
enabled: true
existingClaim: MyAwesomeGiteaMysqlClaim
```
When upgrading, make sure you have the following enabled:
### Admin User
- Persistency for both mariadb + Gitea
- Using `existingGiteaClaim`
- Due to using the [bitnami/mariadb](https://github.com/helm/charts/tree/master/stable/mariadb) chart, make sure to HARDCODE your passwords within `values.yaml`. Or else you'll be unable to update mariadb
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.
```yaml
gitea:
admin:
username: "MyAwesomeGiteaAdmin"
password: "AReallyAwesomeGiteaPassword"
email: "gi@tea.com"
```
### LDAP Settings
Like the admin user the ldap settings can be updated but also disabled or deleted.
```yaml
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
```
## Configuration
Refer to [values.yaml](values.yaml) for the full run-down on defaults.
### Others
The following table lists the configurable parameters of this chart and their default values.
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|statefulset.terminationGracePeriodSeconds| Image to start for this pod | gitea/gitea |
| Parameter | Description | Default |
|---------------------------------------|------------------------------------------------------------------------------------------------------------------------------|---------------------------|
| `images.gitea` | `gitea` image | `gitea/gitea:1.9.3` |
| `images.memcached` | `memcached` image | `memcached:1.5.19-alpine` |
| `images.pullPolicy` | Image pull policy | `IfNotPresent` |
| `images.pullSecrets` | Specify an array of pull secrets | `[]` |
| `memcached.maxItemMemory` | Max item memory | `64` |
| `memcached.verbosity` | Verbosity | `v` |
| `memcached.extendedOptions` | Extended options for memcached | `modern` |
| `ingress.enabled` | Switch to create ingress for this chart deployment | `true` |
| `ingress.hostname ` | Hostname to be used for the ingress | `gitea.local` |
| `ingress.certManager` | Asks if we want to use cert-manager or not (let's encrypt, etc.) | `true` |
| `ingress.annotations` | Annotations used by the ingress | `[]` |
| `ingress.hosts ` | Additional hosts to be used by the ingress | `[]` |
| `ingress.tls ` | TLS secret keys to be used with Gitea | `[]` |
| `service.http.serviceType` | type of kubernetes services used for http i.e. ClusterIP, NodePort or LoadBalancer | `ClusterIP` |
| `service.http.port` | http port for web traffic | `3000` |
| `service.http.NodePort` | Manual NodePort for web traffic | `nil` |
| `service.http.externalPort` | Port exposed on the internet by a load balancer or firewall that redirects to the ingress or NodePort | `8280` |
| `service.http.externalHost` | IP or DNS name exposed on the internet by a load balancer or firewall that redirects to the ingress or Node for http traffic | `gitea.local` |
| `service.ssh.serviceType` | type of kubernetes services used for ssh i.e. ClusterIP, NodePort or LoadBalancer | `ClusterIP` |
| `service.ssh.port` | http port for web traffic | `22` |
| `service.ssh.NodePort` | Manual NodePort for ssh traffic | `nil` |
| `service.ssh.externalPort` | Port exposed on the internet by a load balancer or firewall that redirects to the ingress or NodePort | `nil` |
| `service.ssh.externalHost` | IP or DNS name exposed on the internet by a load balancer or firewall that redirects to the ingress or Node for http traffic | `gitea.local` |
| `resources.gitea.requests.memory` | gitea container memory request | `500Mi` |
| `resources.gitea.requests.cpu` | gitea container request cpu | `1000m` |
| `resources.gitea.limits.memory` | gitea container memory limits | `2Gi` |
| `resources.gitea.limits.cpu` | gitea container CPU/Memory resource requests/limits | `1` |
| `resources.memcached.requests.memory` | memcached container memory request | `64Mi` |
| `resources.memcached.requests.cpu` | memcached container request cpu | `50m` |
| `persistence.enabled` | Create PVCs to store gitea data | `false` |
| `persistence.existingGiteaClaim` | Already existing PVC that should be used for gitea data. | `nil` |
| `persistence.giteaSize` | Size of gitea pvc to create | `10Gi` |
| `persistence.annotations` | Annotations to set on created PVCs | `nil` |
| `persistence.storageClass` | StorageClass to use for dynamic provision if not 'default' | `nil` |
| `podAnnotations` | Annotations to set on the pod | `{}` |
| `mariadb.enabled` | Enable or diable mariadb | `true` |
| `mariadb.replication.enabled` | Enable or diable replication | `false` |
| `mariadb.db.name` | Default name | `gitea` |
| `mariadb.db.user` | Default user | `gitea` |
| `mariadb.persistence.enabled` | Enable or diable persistence | `true` |
| `mariadb.persistence.accessMode` | What access mode to use | `ReadWriteOnce` |
| `mariadb.persistence.size` | What size of database to use | `8Gi` |
| `externalDB.dbUser` | external db user | ` unset` |
| `externalDB.dbPassword` | external db password | ` unset` |
| `externalDB.dbHost` | external db host | ` unset` |
| `externalDB.dbPort` | external db port | ` unset` |
| `externalDB.dbDatabase` | external db database name | ` unset` |
| `config.disableInstaller` | Disable the installer | `false` |
| `config.offlineMode` | Sets Gitea's Offline Mode. Values are `true` or `false`. | `false` |
| `config.requireSignin` | Require Gitea user to be signed in to see any pages. Values are `true` or `false`. | `false` |
| `config.disableRegistration` | Disable Gitea's user registration. Values are `true` or `false`. | `false` |
| `config.openidSignin` | Allow login with OpenID. Values are `true` or `false`. | `true` |
| `nodeSelector` | Node to be selected | `{}` |
| `affinity` | Affinity settings for pod assignment | `{}` |
| `tolerations` | Toleration labels for pod assignment | `[]` |
| `deploymentAnnotations` | Deployment annotations to be used | `{}` |
| `podAnnotations` | Pod deployment annotations to be used | `{}` |
### Image
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|image.repository| Image to start for this pod | gitea/gitea |
|image.version| Image Version | 1.12.2 |
|image.pullPolicy| Image pull policy | Always |
### Persistence
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|persistence.enabled| Enable persistence for Gitea |true|
|persistence.existingClaim| Use an existing claim to store repository information | |
|persistence.size| Size for persistence to store repo information | 10Gi |
|persistence.accessModes|AccessMode for persistence||
|persistence.storageClass|Storage class for repository persistence|standard|
### Ingress
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|ingress.enabled| enable ingress | false|
|ingress.annotations| add ingress annotations | |
|ingress.hosts| add hosts for ingress as string list | git.example.com |
|ingress.tls|add ingress tls settings|[]|
### Service
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|service.http.type| Kubernetes service type for web traffic | ClusterIP |
|service.http.port| Port for web traffic | 3000 |
|service.ssh.type| Kubernetes service type for ssh traffic | ClusterIP |
|service.ssh.port| Port for ssh traffic | 22 |
|service.ssh.annotations| Additional ssh annotations for the ssh service ||
### Gitea Configuration
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|gitea.config | Everything in app.ini can be configured with this dict. See Examples for more details | {} |
### Memcached BuiltIn
Memcached is loaded as a dependency from [Bitnami](https://github.com/bitnami/charts/tree/master/bitnami/memcached) if enabled in the values. Complete Configuration can be taken from their website.
The following parameters are the defaults set by this chart
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|memcached.service.port|Memcached Port| 11211|
### Mysql BuiltIn
Mysql is loaded as a dependency from stable. Configuration can be found from this [website](https://github.com/helm/charts/tree/master/stable/mysql)
The following parameters are the defaults set by this chart
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|mysql.mysqlRootPassword|Password for the root user. Ignored if existing secret is provided|gitea|
|mysql.mysqlUser|Username of new user to create.|gitea|
|mysql.mysqlPassword|Password for the new user. Ignored if existing secret is provided|gitea|
|mysql.mysqlDatabase|Name for new database to create.|gitea|
|mysql.service.port|Port to connect to mysql service|3306|
|mysql.persistence|Persistence size for mysql |10Gi|
### Postgresql BuiltIn
Postgresql is loaded as a dependency from bitnami. Configuration can be found from this [Bitnami](https://github.com/bitnami/charts/tree/master/bitnami/postgresql)
The following parameters are the defaults set by this chart
| Parameter | Description | Default |
|---------------------|-----------------------------------|------------------------------|
|postgresql.global.postgresql.postgresqlDatabase| PostgreSQL database (overrides postgresqlDatabase)|gitea|
|postgresql.global.postgresql.postgresqlUsername| PostgreSQL username (overrides postgresqlUsername)|gitea|
|postgresql.global.postgresql.postgresqlPassword| PostgreSQL admin password (overrides postgresqlPassword)|gitea|
|postgresql.global.postgresql.servicePort|PostgreSQL port (overrides service.port)|5432|
|postgresql.persistence.size| PVC Storage Request for PostgreSQL volume |10Gi|