Skip to content

Conversation

@xdavidwu
Copy link
Contributor

The kubernetes (ingress) provider create services named <namespace>-<service name>-<port>, other kubernetes providers (crd, gateway) also name their services in similiar fashion, combining names from kubernetes with '-'. Most kubernetes resources requires their name to be usable as dns subdomain names only, therefore '-' is also possible in names (actually quite common, like kube-system, kube-controller-manager).

label_replace here before extracts first two part seperated with '-'. The intention here is probably to extract <namespace>-<service name>, but with '-' in namespaces or service names, this breaks and usually generates labels that are not unique. If there are query operation after label_replace, it is also fragile, due to having multiple series with same labels.

This fixes it by removing only @<providername> instead. '@' is invalid for names in most kubernetes resources, so this should be safe.

What does this PR do?

Fix service name extraction on dashboard for traefik on kubernetes.

Motivation

More

  • Added/updated tests
  • Added/updated documentation

Additional Notes

@mmatur
Copy link
Member

mmatur commented May 28, 2024

Hello @xdavidwu,

Thanks for your contribution.

Could you please rebase your PR on branch v2.11?

@xdavidwu
Copy link
Contributor Author

Could you please rebase your PR on branch v2.11?

This issue only exists on branch v3.0 and master. Which one should I target?

@mmatur
Copy link
Member

mmatur commented May 28, 2024

Oops my bad, you can target v3.0 please.

@xdavidwu xdavidwu force-pushed the kubernetes-dashboard-fix-name-extraction branch from 7e706dc to ec320fb Compare May 28, 2024 08:36
@xdavidwu xdavidwu changed the base branch from master to v3.0 May 28, 2024 08:36
@mmatur mmatur added this to the 3.0 milestone May 28, 2024
Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks

Copy link
Member

@rtribotte rtribotte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@kevinpollet kevinpollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

The kubernetes (ingress) provider create services named
`<namespace>-<service name>-<port>`, other kubernetes providers (crd,
gateway) also name their services in similiar fashion, combining names
from kubernetes with '-'. Most kubernetes resources requires their name
to be usable as dns subdomain names only, therefore '-' is also possible
in names (actually quite common, like kube-system,
kube-controller-manager).

label_replace here before extracts first two part seperated with '-'.
The intention here is probably to extract `<namespace>-<service name>`,
but with '-' in namespaces or service names, this breaks and usually
generates labels that are not unique. If there are query operation after
label_replace, it is also fragile, due to having multiple series with
same labels.

This fixes it by removing only `@<providername>` instead. '@' is invalid
for names in most kubernetes resources, so this should be safe.
@kevinpollet kevinpollet force-pushed the kubernetes-dashboard-fix-name-extraction branch from ec320fb to 58ac35b Compare June 5, 2024 14:19
@traefiker traefiker merged commit dc752c7 into traefik:v3.0 Jun 5, 2024
@kevinpollet kevinpollet changed the title grafana: traefik-kubernetes: fix service name label_replace Fix service name label_replace in Grafana Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants