Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Traefik metrics in latest K3s #9

Open
fabltd opened this issue Aug 20, 2021 · 1 comment
Open

Traefik metrics in latest K3s #9

fabltd opened this issue Aug 20, 2021 · 1 comment

Comments

@fabltd
Copy link

fabltd commented Aug 20, 2021

Hi

It seems k3s version v1.21.1+k3s1 that uses Traefik V 2.4.8 does not by default have metrics enabled.

Trying to track down how to make the configuration change.

@jeanpommier
Copy link

Hi @fabltd
I don't know if you found out since then. For the records:

You have to activate the metrics.

It can be done by creating a yaml file in /var/lib/rancher/k3s/server/manifests on the control-plane server, with the following content

apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
  name: traefik
  namespace: kube-system
spec:
  valuesContent: |-
    additionalArguments:
      - '--metrics.prometheus=true'
      - '--metrics.prometheus.entryPoint=metrics'
    ports:
      metrics:
        port: 8082

It is deployed automatically by k3s.

Then you'll have to deploy a service exposing the metrics, and the corresponding serviceMonitor.
I'm using the following config:

  • traefik-metrics-svc.yaml:
    apiVersion: v1
    kind: Service
    metadata:
      name: traefik-metrics-service
      labels:
        app: traefik-metrics
      namespace: kube-system
    spec:
      selector:
        app.kubernetes.io/name: traefik
      ports:
      - name: metrics
        port: 8082
    
  • traefik-servicemonitor.yaml:
    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      labels:
        app: traefik
        release: prometheus
      name: traefik
    spec:
      endpoints:
      - port: metrics
      namespaceSelector:
        matchNames:
        - kube-system
      selector:
        matchLabels:
          app: traefik-metrics
    

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants