https://github.com/thibaut-mouton/cgroupv2-probes-kubernetes
Typescript utils to read metrics in kubernetes pod to check and control memory and cpu from cgroup v2.
https://github.com/thibaut-mouton/cgroupv2-probes-kubernetes
cgroups cgroups-v2 k8s kubernetes linux-kernel prestop readiness-probe typescript
Last synced: 2 months ago
JSON representation
Typescript utils to read metrics in kubernetes pod to check and control memory and cpu from cgroup v2.
- Host: GitHub
- URL: https://github.com/thibaut-mouton/cgroupv2-probes-kubernetes
- Owner: Thibaut-Mouton
- License: mit
- Created: 2024-03-22T21:42:53.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-27T21:39:18.000Z (about 1 year ago)
- Last Synced: 2025-02-18T15:53:28.094Z (3 months ago)
- Topics: cgroups, cgroups-v2, k8s, kubernetes, linux-kernel, prestop, readiness-probe, typescript
- Language: TypeScript
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# CGROUP V2 METRICS
- npm module for reading [cgroupv2](https://docs.kernel.org/admin-guide/cgroup-v2.html) RAM and CPU metrics.
- Reads from /sys/fs/cgroup/.
- Useful for kubernetes probes : readiness, liveness or prestop, all available since v1.25## Installation
```
npm install @mercure/cgroupv2-metrics
```
## Use case- You can use those metrics to have more control over kubernetes pods :
A pod has a heavy load incoming, and you do not want that pod to be reached by kubernetes internal load-balancer. Since kubernetes does not provide load-balancer over resources consumption, you can use a readiness probe, which check metrics every "x" seconds and trigger the probe if RAM and/or CPU are overloaded. This probe will eject the pod from load-balancer by setting the pod "unavailable". Once consumption will decrease to an acceptable level, probe trigger will stop and the pod will be available from load-balancer again.
- Check ```examples``` folder to see how k8s probes can be implemented## Want to work on project ?
With ```devcontainers```, you can easily start up a dev environment on docker with your favorite IDE without download any package required by the project on your OS.
Feel free to open PR and submit issues.Read more on [devcontainers](https://containers.dev)