Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
correction: GCP pricing uses GIB
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Jul 24, 2019
1 parent 7331e8e commit 8c0dfeb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
44 changes: 22 additions & 22 deletions kube_resource_report/gcp-costs-monthly.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ us-east1,custom-per-cpu-core,24.2336
us-east4,custom-per-cpu-core,27.2944
us-west1,custom-per-cpu-core,24.2336
us-west2,custom-per-cpu-core,27.7371
asia-east,custom-per-memory-gb,3.7621
asia-east1,custom-per-memory-gb,3.7621
asia-east2,custom-per-memory-gb,4.3304
asia-northeast,custom-per-memory-gb,3.9578
asia-northeast1,custom-per-memory-gb,3.9578
asia-northeast2,custom-per-memory-gb,3.9578
asia-south1,custom-per-memory-gb,3.7168
asia-southeast,custom-per-memory-gb,3.8176
australia-southeast1,custom-per-memory-gb,4.3903
europe-north1,custom-per-memory-gb,3.4071
europe-west1,custom-per-memory-gb,3.5736
europe-west2,custom-per-memory-gb,3.9834
europe-west3,custom-per-memory-gb,3.9834
europe-west4,custom-per-memory-gb,3.4071
europe-west6,custom-per-memory-gb,4.3304
northamerica-northeast1,custom-per-memory-gb,3.4071
southamerica-east1,custom-per-memory-gb,4.9155
us-central1,custom-per-memory-gb,3.2478
us-east1,custom-per-memory-gb,3.2478
us-east4,custom-per-memory-gb,3.6583
us-west1,custom-per-memory-gb,3.2478
us-west2,custom-per-memory-gb,3.7175
asia-east,custom-per-memory-gib,3.7621
asia-east1,custom-per-memory-gib,3.7621
asia-east2,custom-per-memory-gib,4.3304
asia-northeast,custom-per-memory-gib,3.9578
asia-northeast1,custom-per-memory-gib,3.9578
asia-northeast2,custom-per-memory-gib,3.9578
asia-south1,custom-per-memory-gib,3.7168
asia-southeast,custom-per-memory-gib,3.8176
australia-southeast1,custom-per-memory-gib,4.3903
europe-north1,custom-per-memory-gib,3.4071
europe-west1,custom-per-memory-gib,3.5736
europe-west2,custom-per-memory-gib,3.9834
europe-west3,custom-per-memory-gib,3.9834
europe-west4,custom-per-memory-gib,3.4071
europe-west6,custom-per-memory-gib,4.3304
northamerica-northeast1,custom-per-memory-gib,3.4071
southamerica-east1,custom-per-memory-gib,4.9155
us-central1,custom-per-memory-gib,3.2478
us-east1,custom-per-memory-gib,3.2478
us-east4,custom-per-memory-gib,3.6583
us-west1,custom-per-memory-gib,3.2478
us-west2,custom-per-memory-gib,3.7175
asia-east,f1-micro,6.5745
asia-east1,f1-micro,6.5745
asia-east2,f1-micro,7.7433
Expand Down
12 changes: 6 additions & 6 deletions kube_resource_report/pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
logger = logging.getLogger(__name__)

AVG_DAYS_PER_MONTH = 30.4375
# GiB != GB
ONE_GB = 1000 ** 3
ONE_GIBI = 1024 ** 3

# just assume 60% spot discount
# see also https://aws.amazon.com/ec2/spot/instance-advisor/
Expand Down Expand Up @@ -61,9 +60,9 @@ def get_node_cost(region, instance_type, is_spot, cpu, memory):

if cost is None and instance_type.startswith('custom-'):
per_cpu = NODE_COSTS_MONTHLY.get((region, 'custom-per-cpu-core'))
per_memory = NODE_COSTS_MONTHLY.get((region, 'custom-per-memory-gb'))
per_memory = NODE_COSTS_MONTHLY.get((region, 'custom-per-memory-gib'))
if per_cpu and per_memory:
cost = (cpu * per_cpu) + (memory/ONE_GB * per_memory)
cost = (cpu * per_cpu) + (memory/ONE_GIBI * per_memory)

if cost is None:
logger.warning(f"No cost information for {instance_type} in {region}")
Expand Down Expand Up @@ -93,8 +92,9 @@ def generate_gcp_price_list():
if _type == 'core':
instance_type = 'custom-per-cpu-core'
elif _type == 'ram':
# note: GCP prices are per GB (not per GiB!)
instance_type = 'custom-per-memory-gb'
# note: GCP prices are per GiB (2^30 bytes)
# https://cloud.google.com/compute/all-pricing
instance_type = 'custom-per-memory-gib'
else:
# TODO: handle preemptible etc
instance_type = None
Expand Down

0 comments on commit 8c0dfeb

Please sign in to comment.