Skip to content

pod cpu metrics not reported correctly #19

@travisghansen

Description

@travisghansen

Bug report

Describe the bug

The stats reported by vz-kubelet seem to be the correct data but kubernetes is reporting essentially 100% cpu utilization. For example I have a dormant VM reporting very low usage (per the commands executed to gather stats and fill out the struct). However, running something like this shows essentially 100% cpu utilization:

kubectl describe podmetrics macos
Name:         macos
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:  metrics.k8s.io/v1beta1
Containers:
  Name:  macos
  Usage:
    Cpu:     3983005841n
    Memory:  352348Ki
Kind:        PodMetrics
Metadata:
  Creation Timestamp:  2025-05-13T16:20:38Z
Timestamp:             2025-05-13T16:20:23Z
Window:                15.064s
Events:                <none>

The above pod has cpu request/limits of 4, the stats data reports something like:

{
        "name": "",
        "startTime": null,
        "cpu": {
                "time": "2025-05-13T16:28:53Z",
                "usageNanoCores": 259200000,
                "usageCoreNanoSeconds": 2364000000000
        },
        "memory": {
                "time": "2025-05-13T16:28:53Z",
                "usageBytes": 1135652864,
                "workingSetBytes": 895881216,
                "rssBytes": 895868928
        }
}

To Reproduce

Steps to reproduce the behavior:

Simply run kubectl top pod <podname> or the command above. Or use something like k9s which shows current utilization.

Expected behavior

The kubernetes api reports cpu utilization the roughly matches what's going on in the VM.

Screenshots

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions