Comments (8)
Would this code help to understand the difference between capacity and allocatable ?
// Set Allocatable.
node.Status.Allocatable = make(api.ResourceList)
for k, v := range node.Status.Capacity {
value := *(v.Copy())
if kl.reservation.System != nil {
value.Sub(kl.reservation.System[k])
}
if kl.reservation.Kubernetes != nil {
value.Sub(kl.reservation.Kubernetes[k])
}
if value.Sign() < 0 {
// Negative Allocatable resources don't make sense.
value.Set(0)
}
node.Status.Allocatable[k] = value
}
This is from here https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet_node_status.go#L459
Reservation is defined here
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet.go#L974
// reservation specifies resources which are reserved for non-pod usage, including kubernetes and
// non-kubernetes system processes.
reservation kubetypes.Reservation
from kube-state-metrics.
Interesting, in the code we seem to use the correct values and the values from the status struct should reflect the state you are looking for. I believe these numbers come from cAdvisor through the apiserver. I believe we have seen that behaviour from cAdvisor before, right @fabxc?
from kube-state-metrics.
Looking further into it there are quite a few more constants that describe memory resources. We should figure out which ones are applicable for the purpose you described. At least from our current naming I would expect the same numbers/behavior as you do @rvrignaud .
from kube-state-metrics.
Looking at my local dev cluster it looks like the resources we take should be correct, but I get the same numbers for capacity/allocatable as well directly from the apiserver.
{
"capacity": {
"alpha.kubernetes.io/nvidia-gpu": "0",
"cpu": "1",
"memory": "1021160Ki",
"pods": "110"
},
"allocatable": {
"alpha.kubernetes.io/nvidia-gpu": "0",
"cpu": "1",
"memory": "1021160Ki",
"pods": "110"
},
...
}
from kube-state-metrics.
I recall seeing this issue before and it being an issue in cAdvisor.
Found something similar at least: google/cadvisor#1404
from kube-state-metrics.
Yes, by default capacity and allocatable are the same, but a good administrator will reserve some resources from the node for system processes (systemd, journald, sshd and in many cases kubelet/kube-proxy).
from kube-state-metrics.
@rvrignaud @brancz Kubelet now supports two command line arguments: --kube-reserved
and --system-reserved
. By setting any of both, node allocatable and capacity should be different. Just as what has been mentioned in comment 264933854 by @fabxc.
For now, the value for node allocatable and capacity are correct.
Maybe we can close this. @rvrignaud
from kube-state-metrics.
Closing it
from kube-state-metrics.
Related Issues (20)
- Resource relation metrics HOT 1
- kube_cronjob_status_active doesn't tell if a cronjob is running HOT 1
- Sharded kube state metrics returns stale metrics HOT 4
- custom metrics for resources w/ group="" broken, e.g. Node HOT 6
- Support metrics for Sidecar containers HOT 2
- Metric with type Gauge throwing errors with no reason. HOT 1
- Need help to troubleshoot/understand issue with KSM pods HOT 2
- Wanted to know the ETA or date for next version release as that has some security vulnerability fixes HOT 3
- Some job metrics are missing if job has no conditions HOT 4
- Duplicate sample for ingress path metrics HOT 2
- Duplicate samples for customResourceState metrics HOT 3
- Support for Gateway API metrics HOT 1
- kube-state-metrics doesn't produce metric for Custom Resources HOT 3
- Version is not applied to the container release binary HOT 2
- Version info missing in v2.13.0 HOT 2
- kube-state-metrics jsonnet format wrong HOT 4
- Use PartialObjectMetadata for ConfigMaps and Secrets HOT 1
- `CustomResourceState` does not produce metrics for the aggregation layer if there is no `CustomResourceDefinition` defined HOT 1
- Add metric(s) for KSM errors HOT 2
- Metric "kube_node_role" missing (AKS) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kube-state-metrics.