From 85159ee6632dba98680173540dd5bee8de0d6cdd Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Sun, 14 May 2023 22:07:07 +0200 Subject: [PATCH] feat(traefik): Switch to ServiceMonitors for metric scraping --- README.md | 2 +- traefik/traefik-external/kustomization.yaml | 1 + traefik/traefik-external/service.yaml | 59 ++++++++++---------- traefik/traefik-external/servicemonitor.yaml | 13 +++++ traefik/traefik-internal/kustomization.yaml | 1 + traefik/traefik-internal/service.yaml | 5 ++ traefik/traefik-internal/servicemonitor.yaml | 13 +++++ 7 files changed, 62 insertions(+), 32 deletions(-) create mode 100644 traefik/traefik-external/servicemonitor.yaml create mode 100644 traefik/traefik-internal/servicemonitor.yaml diff --git a/README.md b/README.md index 6fbf8e7..4521b93 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ | Name | Usage | Accessibility | Host | DB type | Additional data | Backup configuration | Loki integration | Prometheus integration | Secret management | Status | Standalone migration | |-------------------------|--------------------------------------|------------------|-------------------------|------------|----------------------|----------------------|------------------|------------------------|------------------------|-----------------------------------|----------------------| -| Traefik | Reverse proxy and load balancer | Public & Private | Socrates & Pythagoras-b | - | - | - | Configured | Not configured | - | Completed5 | Backbone | +| Traefik | Reverse proxy and load balancer | Public & Private | Socrates & Pythagoras-b | - | - | - | Configured | Configured | - | Completed5 | Backbone | | ArgoCD | Declarative GitOPS CD | Private | Pythagoras-b | - | - | - | Configured | Configured | - | Completed | Backbone | | Vaultwarden | Password manager | Public | Pythagoras-b | PostgreSQL | - | 4AM K8s CronJob | Configured | Not available | Configured | Completed | Completed | | Radarr | Movie collection manager | Private | Plato | PostgreSQL | - | - | Configured | Not configured | Not configured | Partial | Awaiting | diff --git a/traefik/traefik-external/kustomization.yaml b/traefik/traefik-external/kustomization.yaml index 93baf7a..a876e32 100644 --- a/traefik/traefik-external/kustomization.yaml +++ b/traefik/traefik-external/kustomization.yaml @@ -5,3 +5,4 @@ resources: - pvc.yaml - deployment.yaml - service.yaml + - servicemonitor.yaml diff --git a/traefik/traefik-external/service.yaml b/traefik/traefik-external/service.yaml index 6830721..d93ab74 100644 --- a/traefik/traefik-external/service.yaml +++ b/traefik/traefik-external/service.yaml @@ -1,36 +1,33 @@ --- # Source: traefik/templates/service.yaml apiVersion: v1 -kind: List +kind: Service metadata: name: traefik-external -items: - - apiVersion: v1 - kind: Service - metadata: - name: traefik-external - labels: - app.kubernetes.io/name: traefik-external - helm.sh/chart: traefik-10.24.2 - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/instance: traefik - annotations: - spec: - type: LoadBalancer - loadBalancerIP: 10.19.66.247 - selector: - app.kubernetes.io/name: traefik - app.kubernetes.io/instance: traefik - ports: - - port: 25565 - name: minecrafttcp - targetPort: "minecrafttcp" - protocol: TCP - - port: 80 # Change port here to accomodate for internal only services - name: web - targetPort: "web" - protocol: TCP - - port: 443 - name: websecure - targetPort: "websecure" - protocol: TCP + labels: + app.kubernetes.io/name: traefik-external + app.kubernetes.io/instance: traefik-external + annotations: +spec: + type: LoadBalancer + loadBalancerIP: 10.18.242.163 + selector: + app.kubernetes.io/name: traefik + app.kubernetes.io/instance: traefik + ports: + - port: 25565 + name: minecrafttcp + targetPort: "minecrafttcp" + protocol: TCP + - port: 80 # Change port here to accomodate for internal only services + name: web + targetPort: "web" + protocol: TCP + - port: 443 + name: websecure + targetPort: "websecure" + protocol: TCP + - port: 9100 + name: metrics + targetPort: "metrics" + protocol: TCP diff --git a/traefik/traefik-external/servicemonitor.yaml b/traefik/traefik-external/servicemonitor.yaml new file mode 100644 index 0000000..15ab9a7 --- /dev/null +++ b/traefik/traefik-external/servicemonitor.yaml @@ -0,0 +1,13 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: traefik-external + labels: + team: core +spec: + selector: + matchLabels: + app.kubernetes.io/name: traefik + endpoints: + - port: metrics + path: /metrics diff --git a/traefik/traefik-internal/kustomization.yaml b/traefik/traefik-internal/kustomization.yaml index 93baf7a..a876e32 100644 --- a/traefik/traefik-internal/kustomization.yaml +++ b/traefik/traefik-internal/kustomization.yaml @@ -5,3 +5,4 @@ resources: - pvc.yaml - deployment.yaml - service.yaml + - servicemonitor.yaml diff --git a/traefik/traefik-internal/service.yaml b/traefik/traefik-internal/service.yaml index 1011981..f656673 100644 --- a/traefik/traefik-internal/service.yaml +++ b/traefik/traefik-internal/service.yaml @@ -8,6 +8,7 @@ metadata: app.kubernetes.io/instance: traefik-inter spec: type: LoadBalancer + loadBalancerIP: 10.10.0.26 selector: app.kubernetes.io/name: traefik-inter app.kubernetes.io/instance: traefik-inter @@ -20,3 +21,7 @@ spec: name: websecure targetPort: "websecure" protocol: TCP + - port: 9100 + name: metrics + targetPort: "metrics" + protocol: TCP diff --git a/traefik/traefik-internal/servicemonitor.yaml b/traefik/traefik-internal/servicemonitor.yaml new file mode 100644 index 0000000..90920df --- /dev/null +++ b/traefik/traefik-internal/servicemonitor.yaml @@ -0,0 +1,13 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: traefik-inter + labels: + team: core +spec: + selector: + matchLabels: + app.kubernetes.io/name: traefik-inter + endpoints: + - port: metrics + path: /metrics