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.
This repository only contains configuration used for Kubernetes.

View File

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

View File

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

View File

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

View File

@ -3,6 +3,8 @@ kind: Service
metadata:
name: gitea-svc
namespace: gitea
labels:
app.kubernetes.io/name: gitea
spec:
ports:
- 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