Skip to content

Conversation

nmn3m
Copy link
Member

@nmn3m nmn3m commented Sep 21, 2025

What this PR does / why we need it:
This PR adds a new metric kube_deployment_owner to track ownership information for Deployments. This is particularly useful for identifying Deployments managed by Operators or other controllers in the Kubernetes ecosystem. The metric includes information about the owner's kind, name, and whether it's a controller, making it easier to understand the ownership hierarchy in clusters.

How does this change affect the cardinality of KSM: increases cardinality
This change adds one new metric with additional labels (owner_kind, owner_name, owner_is_controller) for each Deployment in the cluster.

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

The new metric provides the following information:

  • Owner kind (e.g., Application, CustomResource)
  • Owner name

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 21, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nmn3m
Once this PR has been reviewed and has the lgtm label, please assign catherinef-dev for approval. For more information see the 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

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 21, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Instrumentation Sep 21, 2025
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 21, 2025
@CatherineF-dev
Copy link
Contributor

Could you provide some use cases for this metric?

@nmn3m
Copy link
Member Author

nmn3m commented Sep 23, 2025

@CatherineF-dev

  • Tracking Ownership & Orphaned Deployments: Identifies which Deployments are owned by controllers, and helps quickly find orphaned resources.

  • Debugging, Monitoring & Auditing: Aids in troubleshooting by linking issues to the controller, provides visibility for monitoring, and supports auditing/compliance.

basemetrics.ALPHA,
"",
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
labelKeys := []string{"owner_kind", "owner_name", "owner_is_controller"}
Copy link
Contributor

@CatherineF-dev CatherineF-dev Sep 23, 2025

Choose a reason for hiding this comment

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

What are other possible values other than controller?

Copy link
Member Author

Choose a reason for hiding this comment

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

Application or custom resources

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use an enum instead of boolean here?

Copy link
Member Author

Choose a reason for hiding this comment

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

why we should do this?, I found that owner_is_controller is used in multiple workload like pods, jobs and replicaset, all of them is in boolean form

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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

Add kube_deployment_owner
3 participants