Add support for metrics and pprof (#100)

Adds support for toggling support for `pprof` and metrics:

```yaml
gitea:
  pprofEnabled: true

  metrics:
    enabled: true
    serviceMonitor:
      enabled: true
```

Co-authored-by: josef <josef.nilsen@outlook.com>
Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/100
Reviewed-by: luhahn <luhahn@noreply.gitea.io>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: JosefWN <josefwn@noreply.gitea.io>
Co-committed-by: JosefWN <josefwn@noreply.gitea.io>
This commit is contained in:
JosefWN 2021-01-21 23:45:26 +08:00 committed by techknowlogick
parent 57479bdf37
commit 7f828e87f6
5 changed files with 63 additions and 0 deletions

View File

@ -95,6 +95,16 @@ 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.
```ini
[metrics]
ENABLED = false
```
### External Database
@ -278,6 +288,24 @@ kebab-case:
username-attribute: CN
```
### Metrics and profiling
A Prometheus `/metrics` endpoint on the `HTTP_PORT` and `pprof` profiling endpoints on port 6060 can be enabled under `gitea`. Beware that the metrics endpoint is exposed via the ingress, manage access using ingress annotations for example.
To deploy the `ServiceMonitor`, you first need to ensure that you have deployed `prometheus-operator` and its CRDs: https://github.com/prometheus-operator/prometheus-operator#customresourcedefinitions.
```yaml
gitea:
metrics:
enabled: true
serviceMonitor:
enabled: true
config:
server:
PPROF_ENABLED: true
```
### Pod Annotations
Annotations can be added to the Gitea pod.

View File

@ -15,6 +15,10 @@ stringData:
{{- $_ := set .Values.gitea.config "server" dict -}}
{{- end -}}
{{- if not (hasKey .Values.gitea.config "metrics") -}}
{{- $_ := set .Values.gitea.config "metrics" dict -}}
{{- end -}}
{{- if not (hasKey .Values.gitea.config "database") -}}
{{- $_ := set .Values.gitea.config "database" dict -}}
{{- end -}}
@ -65,6 +69,14 @@ stringData:
{{- if not (hasKey .Values.gitea.config.server "APP_DATA_PATH") -}}
{{- $_ := set .Values.gitea.config.server "APP_DATA_PATH" "/data" -}}
{{- end -}}
{{- if not (hasKey .Values.gitea.config.server "PPROF_ENABLED") -}}
{{- $_ := set .Values.gitea.config.server "PPROF_ENABLED" false -}}
{{- end -}}
{{- /* metrics default settings */ -}}
{{- if not (hasKey .Values.gitea.config.metrics "ENABLED") -}}
{{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}}
{{- end -}}
{{- /* database default settings */ -}}
{{- if .Values.gitea.database.builtIn.postgresql.enabled -}}

View File

@ -0,0 +1,14 @@
{{- if .Values.gitea.metrics.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "gitea.fullname" . }}
labels:
{{- include "gitea.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "gitea.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
{{- end -}}

View File

@ -66,6 +66,10 @@ spec:
containerPort: {{ .Values.gitea.config.server.SSH_LISTEN_PORT }}
- name: http
containerPort: {{ .Values.gitea.config.server.HTTP_PORT }}
{{- if .Values.gitea.config.server.PPROF_ENABLED }}
- name: profiler
containerPort: 6060
{{- end }}
livenessProbe:
tcpSocket:
port: http

View File

@ -105,6 +105,11 @@ gitea:
password: r8sA8CPHD9!bt6d
email: "gitea@local.domain"
metrics:
enabled: false
serviceMonitor:
enabled: false
ldap:
enabled: false
#name: