kubernetes / kube-state-metrics

Add-on agent to generate and expose cluster-level metrics.
https://kubernetes.io/docs/concepts/cluster-administration/kube-state-metrics/
Apache License 2.0
5.36k stars 2k forks source link

`/proxy/stats/summary` returning incorrect PVC capacity bytes #2516

Open exp0nge opened 4 hours ago

exp0nge commented 4 hours ago

What happened:

When querying kubectl get --raw /api/v1/nodes/<node-ip>/proxy/stats/summary, the capacity bytes returned for PVCs are not what are shown in tools like k9s which therefore tell me that tooling built around this endpoint will show incorrect values.

What you expected to happen:

PVC capacity and other metrics show the correct sizes

How to reproduce it (as minimally and precisely as possible):

$ kubectl get --raw "/api/v1/nodes/ip-<>.ec2.internal/proxy/stats/summary"
...
        {
          "time": "2024-09-30T18:27:06Z",
          "availableBytes": 467653439488,
          "capacityBytes": 1623168045056,
          "usedBytes": 1155497828352,
          "inodesFree": 100516333,
          "inodes": 100663296,
          "inodesUsed": 146963,
          "name": "pvc-data",
          "pvcRef": {
            "name": "name-pvc",
            "namespace": "namespace-pvc"
          }
        },
...

Take capacity bytes, convert to GiB/MiB, compare with k9s or other tooling for spec.resources.requests.storage

I used: kubectl get pvc name-pvc -o json to get the spec requests to compare against (which was larger by 125 MiB):

    },
    "spec": {
        "accessModes": [
            "ReadWriteOnce"
        ],
        "resources": {
            "requests": {
                "storage": "9600Gi"
            }
        },

Anything else we need to know?:

Environment:

k8s-ci-robot commented 4 hours ago

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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.