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

Add Metrics for EndpointSlices #1910

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

mrueg
Copy link
Member

@mrueg mrueg commented Nov 25, 2022

What this PR does / why we need it:
Implements https://pkg.go.dev/k8s.io/api/discovery/v1#EndpointSlice
Metrics from endpointslices can be used to identify if specific pods are part of an endpoint and thus discoverable through a service.

kube_endpointslice_info{endpointslice="my-app-75zcw",addresstype="IPv4"} 1
kube_endpointslice_created{endpointslice="my-app-75zcw"} 1.605287362e+09
kube_endpointslice_endpoints{endpointslice="my-app-75zcw",ready="true",serving="true",terminating="false",targetref_kind="Pod",targetref_name="my-app-73967648-75dgx",targetref_namespace="my-namespace",endpoint_nodename="my-node",endpoint_zone="west",address="192.168.1.1"} 1
kube_endpointslice_ports{endpointslice="my-app-75zcw",port_name="http",port_protocol="TCP",port_number="8080"} 1

How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
This resource type is disabled by default as they are very verbose and have a high cardinality.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 25, 2022
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 25, 2022
@mrueg mrueg force-pushed the add-endpointslices branch 3 times, most recently from 9027651 to d122c47 Compare November 26, 2022 00:36
Implements https://pkg.go.dev/k8s.io/api/discovery/v1#EndpointSlice

This resourcetype is disabled by default as they are very verbose and
have a high cardinality.
Metrics from endpointslices can be used to identify if specific pods are
part of an endpoint and thus discoverable through a service.

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
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.

/lgtm
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 26, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 26, 2022
@dgrisonnet
Copy link
Member

/lgtm
/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 1, 2022
@dgrisonnet
Copy link
Member

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 1, 2022
for _, port := range e.Ports {
m = append(m, &metric.Metric{
LabelValues: []string{*port.Name, string(*port.Protocol), strconv.FormatInt(int64(*port.Port), 10)},
LabelKeys: []string{"port_name", "port_protocol", "port_number"},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
LabelKeys: []string{"port_name", "port_protocol", "port_number"},
LabelKeys: []string{"name", "protocol", "number"},

Prefixing the labels by port feels a bit redundant

Copy link
Member

Choose a reason for hiding this comment

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

I noticed afterward that we inherit that choice from the endpoint metrics: https://github.com/kubernetes/kube-state-metrics/blob/master/docs/endpoint-metrics.md.

There is not much we can do about it anymore I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, initially I would have preferred to keep it shorter as well, then decided to stay consistent with endpoints.

}),
),
*generator.NewFamilyGeneratorWithStability(
"kube_endpointslice_endpoints",
Copy link
Member

Choose a reason for hiding this comment

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

I think we are plumbing too maybe information inside of this metric. What would you think about moving the conditions, targetref and addresses into their own metrics? There are some precedence to that kind of split with statuses metrics and kube_endpoint_address.

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to combine everything in it that is in https://pkg.go.dev/k8s.io/api/discovery/v1#Endpoint (which is used in
https://pkg.go.dev/k8s.io/api/discovery/v1#EndpointSlice). This would make it easier for users to query it instead of combining two or more metrics. Do you see any downsides?

@dgrisonnet
Copy link
Member

/lgtm cancel
/unhold

@k8s-ci-robot k8s-ci-robot removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Dec 1, 2022
Copy link
Member

@logicalhan logicalhan left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 1, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fpetkovski, logicalhan, 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 merged commit 44aea58 into kubernetes:master Dec 1, 2022
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.

None yet

5 participants