consul-k8s icon indicating copy to clipboard operation
consul-k8s copied to clipboard

Add support for setting service weights via annotations in Kubernetes Catalog Sync

Open azalenski-branch opened this issue 2 years ago • 0 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Is your feature request related to a problem? Please describe.

According to the documentation Consul supports setting weights for services . Unfortunately currently there is no way of doing that when using consul-k8s, as there is no annotation that can control that + there is no easy way of doing it via Consul API and it looks like the changes will be anyway overwritten.

Feature Description

What would be very useful it to add an additional annotation similar to the existing ones for Consul Catalog Sync, that would control the weights parameter of the service. An example annotation would look like this:

consul.hashicorp.com/service-weight: <number>

This would be later on mapped to the weights parameter for all pods of the respective service.

Use Case(s)

There are multiple use-cases where such annotation will come in handy for the Service Discovery mechanism. An example:

Setting weights for Consul services that span across multiple Kubernetes clusters. Having such annotation would allow us to set weight on example-service deployed on ClusterA to 25% and weight on same service example-service deployed on ClusterB to 75%. This allows to perform weighted routing and can be useful in multiple scenarios such as:

  • Canary releases
  • Haproxy/Nginx Weighted Load Balancing
  • Traffic splitting

Contributions

With some guidance, I can try to prepare an initial PR with the new feature.

azalenski-branch avatar Aug 26 '22 09:08 azalenski-branch