Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[victoria-metrics-k8s-stack] Add routePrefix to VM Components #1260

Open
alihoda opened this issue Aug 20, 2024 · 5 comments
Open

[victoria-metrics-k8s-stack] Add routePrefix to VM Components #1260

alihoda opened this issue Aug 20, 2024 · 5 comments

Comments

@alihoda
Copy link

alihoda commented Aug 20, 2024

Hi. It would be nice if vm-k8s-stack has a option like routePrefix in kube-prometheus-stack that helps to set a root path for each components and so just use one domain for entire stack.
I currently should handle it with ingress.annotations:

ingress:
  select:
    path: /s/?(.*)
    annotations:
      kubernetes.io/ingress.class: "nginx"
      nginx.ingress.kubernetes.io/rewrite-target: /$1
      nginx.ingress.kubernetes.io/use-regex: "true"

As it seems, it is a little messy!! And if use something like anchors to reuse it for other ingresses, then for grafana and vmalertmanger you can not use it because they support the root path option. In the end you need to repeat the necessary annotations for these two!!

@AndrewChubatiuk
Copy link
Contributor

could you please elaborate more about this case?
which services do you want to have ingress for?
in a final configuration do you expect all services to be behind a single ingress? (i'm not aware if nginx ingress supports multiple ingresses with the same host:port, but different paths, like alb controller does)

@alihoda
Copy link
Author

alihoda commented Aug 23, 2024

could you please elaborate more about this case? which services do you want to have ingress for? in a final configuration do you expect all services to be behind a single ingress? (i'm not aware if nginx ingress supports multiple ingresses with the same host:port, but different paths, like alb controller does)

In the vm-k8s-stack, specifically for vmcluster, we typically have Ingress resources for vminsert, vmstorage, and vmselect, with vmselect being the most crucial. Additionally, in both single and cluster modes, vmagent and vmalert also have Ingress options, mainly to provide detailed insights beyond what is available in Grafana dashboards.

For our scenario, the goal is to use a single domain, vm.example.com, with Ingress paths for three key services: vmselect, vmagent, and vmalert (we also have VMAlertMnager and Grafana for that domain too but they are handled with routePrefix and grafana.ini.server.root). The desired paths are as follows:

  • /s for vmselect
  • /a for vmagent
  • /al for vmalert

In the kube-prometheus-stack, there is a routePrefix option (used by components like AlertManager and Prometheus) that allows for rewriting URLs, making it easier to manage multiple services under a single domain. This feature can be seen in the values.yaml file of both vm-k8s-stack and kube-prometheus-stack.

Implementing a similar routePrefix option in vm-k8s-stack would simplify configuration, reducing the need to manage multiple, repetitive annotations across different Ingress resources, especially when dealing with services like Grafana and VMAlertManager, which already support root path customization. This would allow for cleaner, more maintainable Ingress configurations, all while using a single domain with distinct paths for each service.

@AndrewChubatiuk
Copy link
Contributor

hey @alihoda
All VM components have ability to set a custom path prefix using:

<vm-component>:
  spec:
    extraArgs:
      http.pathPrefix: /prefix

The only exception is alertmanager, which has a special property for this case: alertmanager.spec.routePrefix
Additionally I've added a PR, which allows to use prefix from cmd args for vm components and routePrefix of alertmanager as a default path for each component in ingress

@AndrewChubatiuk
Copy link
Contributor

AndrewChubatiuk commented Sep 20, 2024

hey @alihoda
starting 0.25.17 you can set

vmagent:
  spec:
    extraArgs:
      http.pathPrefix: /agent
  ingress:
    enabled: true
    hosts: [anyhost.com]

this will automatically add /agent path to ingress, which you can override using vmagent.ingress.path
are you okay with such approach?

@alihoda
Copy link
Author

alihoda commented Sep 20, 2024

hey @alihoda
starting 0.25.17 you can set

vmagent:
  spec:
    extraArgs:
      http.pathPrefix: /agent
  ingress:
    enabled: true
    hosts: [anyhost.com]

this will automatically add /agent path to ingress, which you can override using vmagent.ingress.path
are you okay with such approach?

That sounds good. That's what I was looking for.
Thanks.

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

No branches or pull requests

2 participants