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

feat: add kube_ingress_status metric #2433

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

isuyyy
Copy link

@isuyyy isuyyy commented Jun 26, 2024

What this PR does / why we need it:
Collects metrics of ingress status. / The info is needed when we use ALB.

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

Which issue(s) this PR fixes:
Fixes #1366

Copy link

linux-foundation-easycla bot commented Jun 26, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 26, 2024
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 26, 2024
@dgrisonnet
Copy link
Member

/triage accepted
/assign @richabanker

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 27, 2024
"kube_ingress_status",
"Ingress status.",
metric.Gauge,
basemetrics.STABLE,
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Fixed here c88e383

for _, ingress := range i.Status.LoadBalancer.Ingress {
for _, port := range ingress.Ports {
ms = append(ms, &metric.Metric{
LabelKeys: []string{"ip", "hostname", "port", "protocol"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need both the ip & the hostname ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering since IPs can keep on changing so cardinality might explode. Just using hostname might suffice?

Copy link
Author

Choose a reason for hiding this comment

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

At first, I just wanted to include all the fields, but as you mentioned, the hostname will suffice.
Made the changes here: 622505e

Copy link
Member

Choose a reason for hiding this comment

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

If we're removing IPs could we end up with duplicate metrics if multiple LB VIPs serve the same hostname (not sure if this is likely at all, maybe with multiple regionally deployed LBs)?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should include IPs (due to the cardinality concern that Richa pointed out).

If we're removing IPs could we end up with duplicate metrics if multiple LB VIPs serve the same hostname (not sure if this is likely at all, maybe with multiple regionally deployed LBs)?

Won't we have unique instance IDs?

Copy link
Member

Choose a reason for hiding this comment

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

With instance IDs you mean in this object https://pkg.go.dev/k8s.io/api/networking/v1#Ingress ?

I don't know if that is the case, I assume there's must be some reason why the object is so convoluted...

https://pkg.go.dev/k8s.io/api/networking/v1#IngressLoadBalancerStatus contains a list of https://pkg.go.dev/k8s.io/api/networking/v1#IngressLoadBalancerIngress (both IP and Hostname are optional, without having looked into the code, I assume you need to set either one or the other?)
which then contains a list of https://pkg.go.dev/k8s.io/api/networking/v1#IngressPortStatus

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 should keep both ip and hostname otherwise this metric won't make much sense since we won't be able to distinguish between the load balancers.
If cardinality is a concern we can always have this metric disabled by default, but here I don't think it is a problem because the number of timeseries for this metric will be limited to the number of Endpoints in the cluster. This is just the theoretical worst case scenario, but in practice it will only be a subset of that since it only includes the endpoints of the loadbalancer. and since the number of Endpoints in a cluster is limited due to scalability limits, this metric will be bounded.

Disclaimer: I am not too knowledgeable about Ingress so for what I know it might just be bounded to the number of Services instead of Endpoints which is even better. It all depends on where the <ip/hostname>: pair come from.

@isuyyy isuyyy requested a review from richabanker July 5, 2024 04:50
@richabanker
Copy link
Contributor

/lgtm

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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: isuyyy, richabanker
Once this PR has been reviewed and has the lgtm label, please assign dgrisonnet for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@richabanker
Copy link
Contributor

/assign @dgrisonnet
for approval

@@ -202,6 +202,28 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
}
}),
),
*generator.NewFamilyGeneratorWithStability(
"kube_ingress_status",
Copy link
Member

@mrueg mrueg Jul 15, 2024

Choose a reason for hiding this comment

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

Suggested change
"kube_ingress_status",
"kube_ingress_status",

I'm a bit torn on this name.
Maybe:
kube_ingress_status_loadbalancer (just wondering if additional fields get added to _status this might be difficult to include)

{
Port: 8888,
Protocol: "TCP",
Error: nil,
Copy link
Member

Choose a reason for hiding this comment

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

Should we expose this error somehow as well?

I assume it can potentially cause high cardinality, but it will be interesting to know if there's an error on the IngressPortStatus?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for ingress status hostname
6 participants