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

endpoints: export number of ports as new metric #1571

Merged
merged 1 commit into from
Nov 10, 2021

Conversation

bavarianbidi
Copy link
Contributor

What this PR does / why we need it:

Export the number of ports per endpoint.

The number of Ports per service can change during their lifetime. When changing a service with type LoadBalancer, the cloud-specific controller mostly change corresponding Loadbalancer-Objects on the cloud-provider side.

If a customer add a new Port to an existing Service-Object, the Endpoint will be updated and the cloud-controller will update the Loadbalancer object on cloud-provider side and a new Listener will be added.
In this special case, the metric can be read as "number of Listeners on a Cloud-Provider Loadbalancer side".

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Signed-off-by: Constanti, Mario mario.constanti@daimler.com

@k8s-ci-robot
Copy link
Contributor

Welcome @bavarianbidi!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 2, 2021
docs/endpoint-metrics.md Outdated Show resolved Hide resolved
@fpetkovski
Copy link
Contributor

fpetkovski commented Oct 6, 2021

Should we consider exposing the actual ports and calculate the count through PromQL? I expect the values to change rarely so there won't be a big cardinality increase.

cc @dgrisonnet

@dgrisonnet
Copy link
Member

Yes, kube-state-metrics shouldn't be responsible for the computation. As an exporter, its only goal is to expose kubernetes objects data as metrics. Any computation such as getting the total number of ports should be done in promQL.

@bavarianbidi
Copy link
Contributor Author

Yes, kube-state-metrics shouldn't be responsible for the computation. As an exporter, its only goal is to expose kubernetes objects data as metrics. Any computation such as getting the total number of ports should be done in promQL.

i'm totally fine with that and it's only consequent (as mostly every kube-state-metric created metric is done that way) for doing this for the new kube_endpoint_port metric.

But especially in endpoint.go the first two existing metrics are also doing calculation. Should i create an issue for that and than we have to decide how/when/if we should drop these stable metrics?

WDYT @dgrisonnet and @fpetkovski

@fpetkovski
Copy link
Contributor

Uh, since those metrics are already stable, we might need to publish a new major release if we want to drop them.

We can leave them as they are for now and if we need the raw data, we can add new metrics.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 8, 2021
@bavarianbidi
Copy link
Contributor Author

bavarianbidi commented Nov 8, 2021

hi @mrueg / @fpetkovski / @fpetkovski

sorry for the late reply. I implemented your findings for now. PTAL
Regarding the "old endpoint metrics aggregation" topic i created #1624

Copy link
Contributor

@fpetkovski fpetkovski left a comment

Choose a reason for hiding this comment

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

There's just one nit from my side, everything else looks really good now.

internal/store/endpoint.go Outdated Show resolved Hide resolved
metric - introduce new kube_endpoint_ports metric:
* export all relevant port infomation (port name, port number and port protocol) from an endpoint

tests - make endpoint tests endpoint.spec aware:
* endpoint port struct with multiple ports need port names per port
* single port struct doesn't need a port name
* port protocol is per default TCP

Signed-off-by: Constanti, Mario <mario.constanti@daimler.com>
@bavarianbidi
Copy link
Contributor Author

There's just one nit from my side, everything else looks really good now.

Done.
I also squashed the commits into one to have a clean history.

@fpetkovski
Copy link
Contributor

/lgtm

Thanks for following through with this contribution!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2021
@mrueg
Copy link
Member

mrueg commented Nov 10, 2021

/lgtm

Thanks for your contribution!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bavarianbidi, fpetkovski, mrueg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 10, 2021
@k8s-ci-robot k8s-ci-robot merged commit 261dbad into kubernetes:master Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants