K8s converts user input quantities to "canonical form":
Before serializing, Quantity will be put in "canonical form". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that: a. No precision is lost b. No fractional digits will be emitted c. The exponent (or suffix) is as large as possible. The sign will be omitted unless the number is negative.
Examples: 1.5 will be serialized as "1500m" 1.5Gi will be serialized as "1536Mi"
Additional examples:
User input
K8s representation
{"memory": "0.9Gi"}
{"memory": "966367641600m"}
{"cpu": "0.30000000000000004"}
{"cpu": "301m"}
Use case
When patching a statefulset's resource limits, it would be handy to be able to compare a quantity's setpoint
Background
K8s converts user input quantities to "canonical form":
Additional examples:
{"memory": "0.9Gi"}
{"memory": "966367641600m"}
{"cpu": "0.30000000000000004"}
{"cpu": "301m"}
Use case
When patching a statefulset's resource limits, it would be handy to be able to compare a quantity's setpoint
to the active podspec
Currently, two equivalent
ResourceRequirements
instances could differ under==
comparison and require manual interconversion.Additional thoughts
parse_quantity
function, but having both lightkube and kubernetes deps is not ideal.class ResourceRequirements
might be ackward.