# Resource Quantities
## Quantities
There are three primary methods are used to specify resource quantities in Kubernetes:%%flashcard%%
1. **Binary SI (International System of Units) units:** This system uses binary prefixes (e.g., Kibibyte, Mebibyte) for quantities, which are based on powers of 2.
2. **Decimal SI units:** This approach uses the standard SI units (e.g., Kilobyte, Megabyte), with prefixes based on powers of 10.
3. **Implicit units:** Quantities specified without explicit units use default settings based on the context (e.g., bytes for memory).
> [!info]
>
> ```text
> 1 Gi == 1 GiB
> 1 G == 1 GB
> ```
>
> B stands for bytes and is typically used to improve clarity, although not in Kubernetes, where bytes are implied.
%%flashcard-end%%
<!--ID: 1711950955901-->
## SI table
Some useful prefixes used in Kubernetes:%%flashcard%%
| Factor (Base 10) | Base 10 Prefix | Symbol | Equivalent (Base 2) | Base 2 Prefix (IEC) | Symbol (IEC) | Value in Base 2 |
| ---------------- | -------------- | ------ | ------------------- | ------------------- | ------------ | ----------------- |
| 10^-3 | milli | m | - | - | - | - |
| 10^0 | (none) | - | 2^0 | (none) | - | 1 |
| 10^3 | kilo | k | 2^10 | kibi | Ki | 1,024 |
| 10^6 | mega | M | 2^20 | mebi | Mi | 1,048,576 |
| 10^9 | giga | G | 2^30 | gibi | Gi | 1,073,741,824 |
| 10^12 | tera | T | 2^40 | tebi | Ti | 1,099,511,627,776 |
%%flashcard-end%%
<!--ID: 1711951272642-->
## CPU
CPU resources are quantified in CPU units, which can represent either virtual or physical CPU cores.
### Examples
- 1.5 CPU cores can be denoted as `1.5` or `1500m` (1500 milliCPU units)
- 0.1 CPU core is equivalent to `0.1` or `100m`
## Memory
- Quantities are primarily measured in bytes
- Examples:
```text
128974848, 129e6, 129M, 128974848000m, 123Mi
```
> [!warning]
> Specifying `400m` for memory allocation is interpreted as `0.4` bytes, which is likely incorrect!
## Storage
- Same as [[#Memory]]
## Resources
- https://github.com/kubernetes/apimachinery/tree/master/pkg/api/resource
- https://kubernetes.io/docs/reference/kubernetes-api/common-definitions/quantity/
- https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/