View Source K8s.Resource.Utilization (k8s v2.5.0)

Deserializers for CPU and Memory values

Summary

Functions

Deserializes CPU quantity

Deserializes memory quantity

Functions

@spec cpu(binary()) :: number()

Deserializes CPU quantity

Examples

Parses whole values

iex> K8s.Resource.Utilization.cpu("3")
3

Parses millicpu values

iex> K8s.Resource.Utilization.cpu("500m")
0.5

Parses decimal values

iex> K8s.Resource.Utilization.cpu("1.5")
1.5
@spec memory(binary()) :: number()

Deserializes memory quantity

Examples

Parses whole values

iex> K8s.Resource.Utilization.memory("1000000")
1000000

Parses decimal values

iex> K8s.Resource.Utilization.memory("10.75")
10.75

Parses decimalSI values

iex> K8s.Resource.Utilization.memory("10M")
10000000

Parses binarySI suffixes

iex> K8s.Resource.Utilization.memory("50Mi")
52428800

Returns the numeric value when the suffix is unrecognized

iex> K8s.Resource.Utilization.memory("50Foo")
50