diff --git a/README.md b/README.md index ab7191a..271dc4f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/templates/gitea/config.yaml b/templates/gitea/config.yaml index 33c47f9..49d5553 100644 --- a/templates/gitea/config.yaml +++ b/templates/gitea/config.yaml @@ -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 -}} diff --git a/templates/gitea/servicemonitor.yaml b/templates/gitea/servicemonitor.yaml new file mode 100644 index 0000000..292297a --- /dev/null +++ b/templates/gitea/servicemonitor.yaml @@ -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 -}} \ No newline at end of file diff --git a/templates/gitea/statefulset.yaml b/templates/gitea/statefulset.yaml index dff1400..c068279 100644 --- a/templates/gitea/statefulset.yaml +++ b/templates/gitea/statefulset.yaml @@ -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 diff --git a/values.yaml b/values.yaml index 760c23e..72dc078 100644 --- a/values.yaml +++ b/values.yaml @@ -105,6 +105,11 @@ gitea: password: r8sA8CPHD9!bt6d email: "gitea@local.domain" + metrics: + enabled: false + serviceMonitor: + enabled: false + ldap: enabled: false #name: