Skip to content

Conversation

yasicar
Copy link

@yasicar yasicar commented Sep 28, 2025

What this PR does / why we need it:

This PR promotes four StatefulSet metrics from EXPERIMENTAL to STABLE status and enhances StatefulSet monitoring documentation with practical examples.
Metrics Promoted to STABLE:
kube_statefulset_status_replicas_available
kube_statefulset_annotations
kube_statefulset_persistentvolumeclaim_retention_policy
kube_statefulset_deletion_timestamp

Why we need it:

  1. Consistency with Kubernetes API Stability: All promoted metrics are based on stable Kubernetes v1 APIs:

Metrics Promoted to STABLE:

  1. kube_statefulset_status_replicas_available

  2. kube_statefulset_annotations

  3. kube_statefulset_persistentvolumeclaim_retention_policy

  4. kube_statefulset_deletion_timestamp

, but the kube-state-metrics metric remained EXPERIMENTAL, This creates inconsistency where identical stable Kubernetes API fields have different stability levels across workload resources in kube-state-metrics.

  1. Better monitoring: The documentation enhancements provide practical PromQL queries and alerting rules that address real-world StatefulSet monitoring needs, including detection of complete outages, rollout issues, and availability problems.

  2. User experience: Removes confusion around metric stability and provides actionable examples for StatefulSet observability.

The promotion is justified because:

  • Same API field as STABLE metrics in Deployments (kube_deployment_status_replicas_available)
  • No changes to the metric since introduction in July 2021
  • Addresses actual monitoring gaps with practical alerting rules

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

Which issue(s) this PR fixes: (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged)
Fixes #

 - Updating kube_statefulset_status_replicas_available from ALPHA to STABLE
- Add comprehensive PromQL examples and troubleshooting queries
- Add major alerting rules for StatefulSet monitoring
- Update tests to reflect STABLE status
Copy link

linux-foundation-easycla bot commented Sep 28, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yasicar
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
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.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 28, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @yasicar!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Instrumentation Sep 28, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 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 Sep 28, 2025
@yasicar yasicar changed the title Promote statefulset available replicas and docs feat: promote StatefulSet availableReplicas to STABLE and enhance docs Sep 28, 2025
- Fix malformed description column spacing in availableReplicas row
- Align with consistent table formatting used by other metrics
- Resolves markdownlint CI failure

Signed-off-by: yasicar <[email protected]>
@yasicar
Copy link
Author

yasicar commented Sep 30, 2025

@CatherineF-dev @mrueg Can you please help me with the review

## Common PromQL Queries

### StatefulSet Health Monitoring

Copy link
Member

@nmn3m nmn3m Oct 3, 2025

Choose a reason for hiding this comment

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

I noticed that you added some PromQL troubleshooting query examples under the metric definition. From my understanding, this file (docs/metrics/workload/statefulset-metrics.md) is meant to document the metrics themselves (type, labels, stability), not usage or example queries.

I think you should remove them.
Thanks.

Copy link
Author

Choose a reason for hiding this comment

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

Hi! Thank you for the feedback.
I added the PromQL examples because I noticed the Pod metrics documentation (docs/metrics/workload/pod-metrics.md) includes similar usage examples and queries, and the main README mentions welcoming "sample usages" contributions.
I was trying to follow that same pattern for consistency. Please add your thoughts.
I'm happy to adjust based on what works best for the project!

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@yasicar, You are right, thanks for mentioning that.

Copy link
Author

Choose a reason for hiding this comment

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

@nmn3m Thanks
This is my first contribution to kube-state-metrics, and I'd really appreciate your help completing this review.

- Promote kube_statefulset_annotations to STABLE
- Promote kube_statefulset_persistentvolumeclaim_retention_policy to STABLE
- Promote kube_statefulset_deletion_timestamp to STABLE

All metrics are based on stable Kubernetes v1 APIs:
- metadata.annotations (v1 stable)
- spec.persistentVolumeClaimRetentionPolicy (v1 stable)
- metadata.deletionTimestamp (v1 stable)

Addresses consistency gap between kube-state-metrics stability
labels and underlying Kubernetes API stability."
@yasicar yasicar changed the title feat: promote StatefulSet availableReplicas to STABLE and enhance docs feat: promote StatefulSet metrics to STABLE and enhance docs Oct 4, 2025
"The number of available replicas per StatefulSet.",
metric.Gauge,
basemetrics.ALPHA,
basemetrics.STABLE,
Copy link
Member

@nmn3m nmn3m Oct 5, 2025

Choose a reason for hiding this comment

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

This metric will need to be in BETA for a quite time then we can promote it to STABLE,
you can read this as I have the same situation before, #2749 (comment)

Copy link
Author

@yasicar yasicar Oct 5, 2025

Choose a reason for hiding this comment

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

@nmn3m
Sure Thanks
I have addressed your comment and updated the entire PR to promote these metrics to BETA instead of STABLE.
d843208

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.

3 participants