-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Add support for endpoint topology routing hints #2090
Conversation
Welcome @MarkSRobinson! |
Fix goimports Fix gocritic issue
4ea5a45
to
5968a5e
Compare
Thanks for your contribution! Also please review the CLA and sign it, otherwise we are unable to accept your change. |
@mrueg I've changed the base to I've signed the CLA too. |
@mrueg This PR is ready to go when you're ready. |
/triage accepted |
internal/store/endpointslice_test.go
Outdated
@@ -17,6 +17,7 @@ import ( | |||
"testing" | |||
|
|||
corev1 "k8s.io/api/core/v1" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add a blank line here
Co-authored-by: Manuel Rüger <manuel@rueg.eu>
Co-authored-by: Manuel Rüger <manuel@rueg.eu>
@MarkSRobinson if you can remove the Dockerfile changes, we can get this merged. :) |
@mrueg Let me clean that up. I found that building for ARM was was easier if we pulled the Go parameters from the Docker build target environment. This let's us build it in k8s super easily. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest creating a new metric kube_endpointslice_endpoints_hints
internal/store/endpointslice.go
Outdated
newlabelValues = append(newlabelValues, address) | ||
|
||
// Hint is populated when the endpoint is configured to be zone aware and preferentially route requests to its local zone. | ||
if ep.Hints != nil && len(ep.Hints.ForZones) > 0 { | ||
|
||
// Because each endpoint can have multiple zones, we need to create a metric for each zone. | ||
// and we need to make sure we aren't adding the hint label repeatedly, we need to copy the array | ||
for _, zone := range ep.Hints.ForZones { | ||
zoneLabelValues := make([]string, len(newlabelValues)) | ||
copy(zoneLabelValues, newlabelValues) | ||
zoneLabelValues = append(zoneLabelValues, zone.Name) | ||
m = append(m, &metric.Metric{ | ||
LabelKeys: append(labelKeys, "hint"), | ||
LabelValues: zoneLabelValues, | ||
Value: 1, | ||
}) | ||
} | ||
} else { | ||
m = append(m, &metric.Metric{ | ||
LabelKeys: labelKeys, | ||
LabelValues: newlabelValues, | ||
Value: 1, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't need to be in the loop iterating over addresses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarkSRobinson this is the comment I was mentioning 🙂
@mrueg I'm ready to merge this PR if you are. |
Can you address @dgrisonnet's comment here please? #2090 (comment) |
@dgrisonnet Can you explain why you want a new metric instead of adding to the existing one? |
@MarkSRobinson it is generally a better practice to keep metrics focus on only one purpose as they become more readable and easier to use. So that's why I am suggesting to create a new metric dedicated to the hints rather than adding yet another label to the already very packed endpoints metric. |
Hi @MarkSRobinson, we are planning to start cutting a new release of kube-state-metrics Wednesday. Do you think you'll be able to address the comments by then? |
@dgrisonnet yeah, I can get to this tomorrow |
@dgrisonnet It's ready if you want to take a look |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MarkSRobinson, 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 |
Remove unneeded label
If someone can kick off another build, we can get this merged. |
Merging manually to squash the commits. |
What this PR does / why we need it:
This PR adds support for reporting the topology routing hints applied to
Endpoint
objects in kubernetes. This is useful to check if the underlying network layer has hints enabled or if it's been disabled. This will let users diagnose if they had topology aware routing enabled or disable in the networking configuration.How does this change affect the cardinality of KSM: Increases, if people have topology aware routing enabled and working.