View Source K8s.Resource.Utilization (k8s v1.1.1)

Deserializers for CPU and Memory values

Link to this section Summary

Functions

Deserializes CPU quantity

Deserializes memory quantity

Link to this section Functions

Specs

cpu(binary()) :: number()

Deserializes CPU quantity

examples

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

Specs

memory(binary()) :: number()

Deserializes memory quantity

examples

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