k8s-resource-parser
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

k8s-resource-parser (node)

Parses the strings used by Kubernetes (K8s) to represent memory and cpu requests and limits.

Only use when you expect correct strings (e.g. coming directly from the K8s API), as the parser isn't designed to handle maliciously-crafted inputs.

Example:

const { parseQuantity } = require('k8s-resource-parser');

parseQuantity("300m"); // Returns 0.3
parseQuantity("2K"); // Returns 2000
parseQuantity("2Ki"); // Returns 2048

Note that kubernetes doesn't represent these quantities as floats internally, so there may be slight discrepancies in the parse results given by this package and the results used in Kubernetes (thanks to floating point imprecision).

Readme

Keywords

none

Package Sidebar

Install

npm i k8s-resource-parser

Weekly Downloads

112

Version

0.2.2

License

MIT

Unpacked Size

12.9 kB

Total Files

9

Last publish

Collaborators

  • ethanresnick