feat(serviceMonitor): custom configuration (#710)
This patch extends the serviceMonitor resource to specify a custom TLS configuration used by prometheus to scrape the metrics. Furthermore, the interval and scrapeTimeout can now be adapted without changing the global defaults of the prometheus instance. Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/710 Reviewed-by: pat-s <pat-s@noreply.gitea.com> Co-authored-by: Markus Pesch <markus.pesch@cryptic.systems> Co-committed-by: Markus Pesch <markus.pesch@cryptic.systems>
This commit is contained in:
parent
77aa11a3bb
commit
e636984db1
39
README.md
39
README.md
@ -1001,23 +1001,28 @@ To comply with the Gitea helm chart definition of the digest parameter, a "custo
|
|||||||
|
|
||||||
### Gitea
|
### Gitea
|
||||||
|
|
||||||
| Name | Description | Value |
|
| Name | Description | Value |
|
||||||
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------- |
|
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------------- |
|
||||||
| `gitea.admin.username` | Username for the Gitea admin user | `gitea_admin` |
|
| `gitea.admin.username` | Username for the Gitea admin user | `gitea_admin` |
|
||||||
| `gitea.admin.existingSecret` | Use an existing secret to store admin user credentials | `nil` |
|
| `gitea.admin.existingSecret` | Use an existing secret to store admin user credentials | `nil` |
|
||||||
| `gitea.admin.password` | Password for the Gitea admin user | `r8sA8CPHD9!bt6d` |
|
| `gitea.admin.password` | Password for the Gitea admin user | `r8sA8CPHD9!bt6d` |
|
||||||
| `gitea.admin.email` | Email for the Gitea admin user | `gitea@local.domain` |
|
| `gitea.admin.email` | Email for the Gitea admin user | `gitea@local.domain` |
|
||||||
| `gitea.admin.passwordMode` | Mode for how to set/update the admin user password. Options are: initialOnlyNoReset, initialOnlyRequireReset, and keepUpdated | `keepUpdated` |
|
| `gitea.admin.passwordMode` | Mode for how to set/update the admin user password. Options are: initialOnlyNoReset, initialOnlyRequireReset, and keepUpdated | `keepUpdated` |
|
||||||
| `gitea.metrics.enabled` | Enable Gitea metrics | `false` |
|
| `gitea.metrics.enabled` | Enable Gitea metrics | `false` |
|
||||||
| `gitea.metrics.serviceMonitor.enabled` | Enable Gitea metrics service monitor | `false` |
|
| `gitea.metrics.serviceMonitor.enabled` | Enable Gitea metrics service monitor. Requires, that `gitea.metrics.enabled` is also set to true, to enable metrics generally. | `false` |
|
||||||
| `gitea.ldap` | LDAP configuration | `[]` |
|
| `gitea.metrics.serviceMonitor.interval` | Interval at which metrics should be scraped. If not specified Prometheus' global scrape interval is used. | `""` |
|
||||||
| `gitea.oauth` | OAuth configuration | `[]` |
|
| `gitea.metrics.serviceMonitor.relabelings` | RelabelConfigs to apply to samples before scraping. | `[]` |
|
||||||
| `gitea.config.server.SSH_PORT` | SSH port for rootlful Gitea image | `22` |
|
| `gitea.metrics.serviceMonitor.scheme` | HTTP scheme to use for scraping. For example `http` or `https`. Default is http. | `""` |
|
||||||
| `gitea.config.server.SSH_LISTEN_PORT` | SSH port for rootless Gitea image | `2222` |
|
| `gitea.metrics.serviceMonitor.scrapeTimeout` | Timeout after which the scrape is ended. If not specified, global Prometheus scrape timeout is used. | `""` |
|
||||||
| `gitea.additionalConfigSources` | Additional configuration from secret or configmap | `[]` |
|
| `gitea.metrics.serviceMonitor.tlsConfig` | TLS configuration to use when scraping the metric endpoint by Prometheus. | `{}` |
|
||||||
| `gitea.additionalConfigFromEnvs` | Additional configuration sources from environment variables | `[]` |
|
| `gitea.ldap` | LDAP configuration | `[]` |
|
||||||
| `gitea.podAnnotations` | Annotations for the Gitea pod | `{}` |
|
| `gitea.oauth` | OAuth configuration | `[]` |
|
||||||
| `gitea.ssh.logLevel` | Configure OpenSSH's log level. Only available for root-based Gitea image. | `INFO` |
|
| `gitea.config.server.SSH_PORT` | SSH port for rootlful Gitea image | `22` |
|
||||||
|
| `gitea.config.server.SSH_LISTEN_PORT` | SSH port for rootless Gitea image | `2222` |
|
||||||
|
| `gitea.additionalConfigSources` | Additional configuration from secret or configmap | `[]` |
|
||||||
|
| `gitea.additionalConfigFromEnvs` | Additional configuration sources from environment variables | `[]` |
|
||||||
|
| `gitea.podAnnotations` | Annotations for the Gitea pod | `{}` |
|
||||||
|
| `gitea.ssh.logLevel` | Configure OpenSSH's log level. Only available for root-based Gitea image. | `INFO` |
|
||||||
|
|
||||||
### LivenessProbe
|
### LivenessProbe
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{{- if .Values.gitea.metrics.serviceMonitor.enabled -}}
|
{{- if and .Values.gitea.metrics.enabled .Values.gitea.metrics.serviceMonitor.enabled -}}
|
||||||
apiVersion: monitoring.coreos.com/v1
|
apiVersion: monitoring.coreos.com/v1
|
||||||
kind: ServiceMonitor
|
kind: ServiceMonitor
|
||||||
metadata:
|
metadata:
|
||||||
@ -14,4 +14,21 @@ spec:
|
|||||||
{{- include "gitea.selectorLabels" . | nindent 6 }}
|
{{- include "gitea.selectorLabels" . | nindent 6 }}
|
||||||
endpoints:
|
endpoints:
|
||||||
- port: http
|
- port: http
|
||||||
|
{{- if .Values.gitea.metrics.serviceMonitor.interval }}
|
||||||
|
interval: {{ .Values.gitea.metrics.serviceMonitor.interval }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.gitea.metrics.serviceMonitor.relabelings }}
|
||||||
|
relabelings:
|
||||||
|
{{- . | toYaml | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.gitea.metrics.serviceMonitor.scheme }}
|
||||||
|
scheme: {{ .Values.gitea.metrics.serviceMonitor.scheme }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.gitea.metrics.serviceMonitor.scrapeTimeout }}
|
||||||
|
scrapeTimeout: {{ .Values.gitea.metrics.serviceMonitor.scrapeTimeout }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.gitea.metrics.serviceMonitor.tlsConfig }}
|
||||||
|
tlsConfig:
|
||||||
|
{{- . | toYaml | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
89
unittests/servicemonitor/basic.yaml
Normal file
89
unittests/servicemonitor/basic.yaml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
suite: ServiceMonitor template (basic)
|
||||||
|
release:
|
||||||
|
name: gitea-unittests
|
||||||
|
namespace: testing
|
||||||
|
templates:
|
||||||
|
- templates/gitea/servicemonitor.yaml
|
||||||
|
tests:
|
||||||
|
- it: skips rendering by default
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
- it: renders default ServiceMonitor object with gitea.metrics.enabled=true
|
||||||
|
set:
|
||||||
|
gitea.metrics.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
- it: renders default ServiceMonitor object with gitea.metrics.serviceMonitor.enabled=true
|
||||||
|
set:
|
||||||
|
gitea.metrics.serviceMonitor.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
- it: renders defaults
|
||||||
|
set:
|
||||||
|
gitea.metrics.enabled: true
|
||||||
|
gitea.metrics.serviceMonitor.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- containsDocument:
|
||||||
|
kind: ServiceMonitor
|
||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
name: gitea-unittests
|
||||||
|
- notExists:
|
||||||
|
path: metadata.annotations
|
||||||
|
- notExists:
|
||||||
|
path: spec.endpoints[0].interval
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].port
|
||||||
|
value: http
|
||||||
|
- notExists:
|
||||||
|
path: spec.endpoints[0].scheme
|
||||||
|
- notExists:
|
||||||
|
path: spec.endpoints[0].scrapeTimeout
|
||||||
|
- notExists:
|
||||||
|
path: spec.endpoints[0].tlsConfig
|
||||||
|
- it: renders custom scrape interval
|
||||||
|
set:
|
||||||
|
gitea.metrics.enabled: true
|
||||||
|
gitea.metrics.serviceMonitor.enabled: true
|
||||||
|
gitea.metrics.serviceMonitor.interval: 30s
|
||||||
|
gitea.metrics.serviceMonitor.scrapeTimeout: 5s
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].interval
|
||||||
|
value: 30s
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].scrapeTimeout
|
||||||
|
value: 5s
|
||||||
|
- it: renders custom tls config
|
||||||
|
set:
|
||||||
|
gitea.metrics.enabled: true
|
||||||
|
gitea.metrics.serviceMonitor.enabled: true
|
||||||
|
gitea.metrics.serviceMonitor.scheme: https
|
||||||
|
gitea.metrics.serviceMonitor.tlsConfig.caFile: /etc/prometheus/tls/ca.crt
|
||||||
|
gitea.metrics.serviceMonitor.tlsConfig.certFile: /etc/prometheus/tls/tls.crt
|
||||||
|
gitea.metrics.serviceMonitor.tlsConfig.keyFile: /etc/prometheus/tls/tls.key
|
||||||
|
gitea.metrics.serviceMonitor.tlsConfig.insecureSkipVerify: false
|
||||||
|
gitea.metrics.serviceMonitor.tlsConfig.serverName: gitea-unittest
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].scheme
|
||||||
|
value: https
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].tlsConfig.caFile
|
||||||
|
value: /etc/prometheus/tls/ca.crt
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].tlsConfig.certFile
|
||||||
|
value: /etc/prometheus/tls/tls.crt
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].tlsConfig.keyFile
|
||||||
|
value: /etc/prometheus/tls/tls.key
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].tlsConfig.insecureSkipVerify
|
||||||
|
value: false
|
||||||
|
- equal:
|
||||||
|
path: spec.endpoints[0].tlsConfig.serverName
|
||||||
|
value: gitea-unittest
|
12
values.yaml
12
values.yaml
@ -356,13 +356,23 @@ gitea:
|
|||||||
passwordMode: keepUpdated
|
passwordMode: keepUpdated
|
||||||
|
|
||||||
## @param gitea.metrics.enabled Enable Gitea metrics
|
## @param gitea.metrics.enabled Enable Gitea metrics
|
||||||
## @param gitea.metrics.serviceMonitor.enabled Enable Gitea metrics service monitor
|
## @param gitea.metrics.serviceMonitor.enabled Enable Gitea metrics service monitor. Requires, that `gitea.metrics.enabled` is also set to true, to enable metrics generally.
|
||||||
|
## @param gitea.metrics.serviceMonitor.interval Interval at which metrics should be scraped. If not specified Prometheus' global scrape interval is used.
|
||||||
|
## @param gitea.metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping.
|
||||||
|
## @param gitea.metrics.serviceMonitor.scheme HTTP scheme to use for scraping. For example `http` or `https`. Default is http.
|
||||||
|
## @param gitea.metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended. If not specified, global Prometheus scrape timeout is used.
|
||||||
|
## @param gitea.metrics.serviceMonitor.tlsConfig TLS configuration to use when scraping the metric endpoint by Prometheus.
|
||||||
metrics:
|
metrics:
|
||||||
enabled: false
|
enabled: false
|
||||||
serviceMonitor:
|
serviceMonitor:
|
||||||
enabled: false
|
enabled: false
|
||||||
# additionalLabels:
|
# additionalLabels:
|
||||||
# prometheus-release: prom1
|
# prometheus-release: prom1
|
||||||
|
interval: ""
|
||||||
|
relabelings: []
|
||||||
|
scheme: ""
|
||||||
|
scrapeTimeout: ""
|
||||||
|
tlsConfig: {}
|
||||||
|
|
||||||
## @param gitea.ldap LDAP configuration
|
## @param gitea.ldap LDAP configuration
|
||||||
ldap:
|
ldap:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user