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

Custom resource metrics #2286

Closed
robbie-demuth opened this issue Aug 6, 2021 · 15 comments
Closed

Custom resource metrics #2286

robbie-demuth opened this issue Aug 6, 2021 · 15 comments
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@robbie-demuth
Copy link

robbie-demuth commented Aug 6, 2021

What do you want to happen?

Prior to the Operator Framework's Operator SDK re-architecting itself as a Kubebuilder plugin, it contained libraries (since deleted in operator-framework/operator-sdk#3249) for generating and serving custom resource metrics (implemented using libraries from kube-state-metrics) and scaffolded operators to invoke said libraries on startup. As a result, operators built using the Operator SDK not only exposed the standard controller-runtime metrics, but also simple metrics about the existence of custom resources managed by the controller (i.e. <KIND>_info{<KIND>="<NAME>", namespace="<NAMESPACE>"} 1).

It'd be nice to provide these metrics for free via Kubebuilder's scaffolding or at least provide an easy way for operator developers to opt-in.

If possible, it'd also be nice to provide an easy, pluggable way for operator developers to declaratively instrument their operators with custom (adjective) custom resource metrics without having to do so in Reconcile (as documented by https://book.kubebuilder.io/reference/metrics.html#publishing-additional-metrics). For example, if a custom resource has a simple string field in its status subresource, it'd be nice to provide an API that allows operator developers to provide a metric name suffix, label name, and function for deriving label values from custom resources so that the controller generates and serves these metrics separately from Reconcile - preventing developers from having to instrument Reconcile wherever they update the status subresource's string field.

I wasn't sure whether to open this issue against kubebuilder or controller-runtime. I'm more than happy to move it to controller-runtime if desired. I also considered opening this issue against https://github.com/operator-framework/operator-lib since it's maintained as part of the Operator Framework. Alternatively, I could imagine the simple "info" metrics for custom resources being a feature request against kube-state-metrics. What do you all think?

Thanks!

Extra Labels

No response

@robbie-demuth robbie-demuth added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 6, 2021
@robbie-demuth
Copy link
Author

robbie-demuth commented Aug 6, 2021

RE my kube-state-metrics comment at the end, it looks like there have been some feature requests over there. The older of these two was closed because the maintainers felt that such metrics were the responsibility of operators. The other is still open and it looks like implementation is underway

kubernetes/kube-state-metrics#457
kubernetes/kube-state-metrics#1210

EDIT

It looks like the second of these two is focusing on custom resource definitions, not custom resources

@rashmigottipati
Copy link
Contributor

@robbie-demuth Sounds interesting! Could you please describe some use cases on how you would use these standard controller runtime and metrics about existence of CRs?

@robbie-demuth
Copy link
Author

The simple "info" metric without additional labels could be used to count custom resources by namespace, cluster, etc. Making additional labels or metrics pluggable, however, really opens up the door to anything

@rashmigottipati
Copy link
Contributor

/cc @camilamacedo86

@camilamacedo86
Copy link
Member

camilamacedo86 commented Aug 28, 2021

Hi @robbie-demuth,

Thank you to raise this issue.

Note that it was desirable in the past: #1068
I think that would be fit very well in a plugin to allow opt-in. See: https://book.kubebuilder.io/plugins/plugins.html
WDYT?

Please, feel free to contribute to this implementation. Your collab is very welcome.

@camilamacedo86 camilamacedo86 added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Aug 28, 2021
@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 26, 2021
@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 26, 2021
@camilamacedo86
Copy link
Member

/remove-lifecycle rotten

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jan 13, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 1, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 1, 2022
@camilamacedo86 camilamacedo86 added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Jun 8, 2022
@chrischdi
Copy link
Member

Maybe worth to note that kube-state-metrics now supports custom resource definitions: kubernetes/kube-state-metrics#1710

Although it does not yet work for _info metrics: kubernetes/kube-state-metrics#1755

@camilamacedo86
Copy link
Member

@Kavinjsir,

This one is related to the metrics so you might like to check it out. I think we need just to see how we could add the kube-state-metrics to kubebuilder.

@chrischdi
Copy link
Member

Would be a great thing to have and at the Cluster API project would be interested in it too

I was about to ask the question in a new issue at kube-state-metrics if that is a reasonable way forward.

Happy to help working on it!

@Kavinjsir
Copy link
Contributor

Sounds good! I'd be glad to work on this!

@Kavinjsir
Copy link
Contributor

/assign

@k8s-triage-robot
Copy link

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. and removed triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Jan 18, 2024
@robbie-demuth
Copy link
Author

kube-state-metrics now provides a declarative way to define custom resource state metrics, which our organization uses with great success, so I'm going to go ahead and close this

https://github.com/kubernetes/kube-state-metrics/blob/main/docs/customresourcestate-metrics.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants