While I explored yaml definitions of Kubernetes templates, I stumbled across different definitions of sizes. First I thought it's about the apiVersions but they are the same. So what is the difference there? Which are right when both are the same?
storage: 5G
and storage: 5Gi
volumeClaimTemplates:
- metadata:
name: mongo-persistent-storage
spec:
resources:
requests:
storage: 2Gi
see here in detail: https://github.com/cvallance/mongo-k8s-sidecar/blob/master/example/StatefulSet/mongo-statefulset.yaml
and this one:
volumeClaimTemplates:
- metadata:
name: mongo-persistent-storage
spec:
resources:
requests:
storage: 5G
here in detail: https://github.com/openebs/openebs/blob/master/k8s/demo/mongodb/mongo-statefulset.yml
From Kubernetes source:
Limits and requests for memory are measured in bytes. You can express memory as a plain integer or as a fixed-point integer using one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki. For example, the following represent roughly the same value:
128974848, 129e6, 129M, 123Mi
So those are the "bibyte" counterparts, like user2864740 commented.
A little info on those orders of magnitude:
The kibibyte was designed to replace the kilobyte in those computer science contexts in which the term kilobyte is used to mean 1024 bytes. The interpretation of kilobyte to denote 1024 bytes, conflicting with the SI definition of the prefix kilo (1000), used to be common.
So, as you can see, 5G means 5 Gigabytes while 5Gi means 5 Gibibytes. They amount to:
Therefore, in terms of size, they are not the same.
Exactly, one of them (G) is power of ten, while the other one (Gi) is power of two. So,
These are different units - one of the are in Binary prefix and the other are in Decimal prefix.
Simply said, the units such as M, G, T are based on power of 10 - multiplies of 1000. The units such as Mi, Gi, Ti are based on power of 2 - multiplies of 1024.