Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes size definitions: What's the difference of "Gi" and "G"?

Tags:

kubernetes

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

like image 301
Jan Avatar asked Jun 11 '18 19:06

Jan


People also ask

What is the difference between G and GI?

To recap the debate between GB vs GiB: both prefixes are units of measurement on digital devices. GB is the traditional, metric style of measurement with 1 GB equaling 1,000³ bytes. GiB is the binary method; which is the way computers measure data at 1024³ bytes.

What does GI stand for in storage?

GiB (Gibibytes) is a standard unit used in the field of data processing and transmission and is defined as base 1024 rather than base 1000. For example, 1 GB is defined as 1000³ bytes, whereas 1 GiB is defined as 1024³ bytes.

How many bytes is 1Gi?

A byte – a GiB is comprised of 1,073,741,824 bytes. A kibibyte (KiB) – a GiB is comprised of 1,048,576 KiB. A mebibyte (MiB) – a GiB is comprised of 1,024 MiB.

What is 1Gi?

1Gi = 2³⁰ = 1,073,741,824 bytes. Mi = MiB = Mebibyte. 1Mi = 2²⁰ = 1,048,576 bytes. Ki = KiB = Kibibyte.


Video Answer


2 Answers

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:

  • 5 G = 5000000 KB / 5000 MB
  • 5 Gi = 5368709.12 KB / 5368.70 MB

Therefore, in terms of size, they are not the same.

like image 128
Diego Victor de Jesus Avatar answered Sep 21 '22 15:09

Diego Victor de Jesus


Exactly, one of them (G) is power of ten, while the other one (Gi) is power of two. So,

  • 10^3 is power of ten. the result is 1000, or 1G
  • 2^10 is power of two. the result is 1024, or 1Gi
like image 39
suren Avatar answered Sep 20 '22 15:09

suren