feat(metrics): Add metric scraping

Add ServiceMonitor resource to scrape /metrics endpoint.
Said endpoint cannot be scrapped from outside of the cluster, as a special IngressRoute Middleware prevents the exposition of said endpoint.
This commit is contained in:
Tanguy Herbron 2023-07-06 13:49:33 +02:00
parent 5452633f37
commit 1830d126a5
6 changed files with 46 additions and 21 deletions

View File

@ -2,3 +2,4 @@
Front end for Git, with integrated Container Registry and CI/CD capabilities. Front end for Git, with integrated Container Registry and CI/CD capabilities.
This repository only contains configuration used for Kubernetes. This repository only contains configuration used for Kubernetes.

View File

@ -9,6 +9,7 @@ data:
GITEA__server__DISABLE_SSH: "true" GITEA__server__DISABLE_SSH: "true"
GITEA__security__INSTALL_LOCK: "true" GITEA__security__INSTALL_LOCK: "true"
GITEA__service__DISABLE_REGISTRATION: "true" GITEA__service__DISABLE_REGISTRATION: "true"
GITEA__metrics__ENABLED: "true"
#app.ini: | #app.ini: |
# APP_NAME = K8s implementation # APP_NAME = K8s implementation
# RUN_MODE = prod # RUN_MODE = prod

View File

@ -1,23 +1,29 @@
apiVersion: networking.k8s.io/v1 apiVersion: traefik.containo.us/v1alpha1
kind: Ingress kind: Middleware
metadata:
name: replace-regex
namespace: gitea
spec:
replacePathRegex:
regex: "^/metrics"
replacement: "/"
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata: metadata:
name: gitea-ingress name: gitea-ingress
namespace: gitea namespace: gitea
annotations: annotations:
kubernetes.io/ingress.class: "traefik" kubernetes.io/ingress.class: "traefik"
spec: spec:
tls: entryPoints:
- secretName: gitea-beta-tls - websecure
hosts: routes:
- git.beta.halia.dev - match: Host(`git.beta.halia.dev`) && PathPrefix(`/`)
rules: kind: Rule
- host: git.beta.halia.dev middlewares:
http: - name: replace-regex
paths: services:
- path: / - name: gitea-svc
pathType: Prefix port: 80
backend:
service:
name: gitea-svc
port:
number: 80

View File

@ -5,6 +5,7 @@ resources:
- namespace.yaml - namespace.yaml
- database.yaml - database.yaml
- service.yaml - service.yaml
- servicemonitor.yaml
- ingress.yaml - ingress.yaml
- configmap.yaml - configmap.yaml
- admin-creator.yaml - admin-creator.yaml

View File

@ -3,6 +3,8 @@ kind: Service
metadata: metadata:
name: gitea-svc name: gitea-svc
namespace: gitea namespace: gitea
labels:
app.kubernetes.io/name: gitea
spec: spec:
ports: ports:
- name: http - name: http

View File

@ -0,0 +1,14 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: gitea
namespace: gitea
labels:
team: core
spec:
selector:
matchLabels:
app.kubernetes.io/name: gitea
endpoints:
- port: http
path: /metrics