|
89 | 89 | GOOGLE_ANALYTICS = getenv('GOOGLE_ANALYTICS', False) |
90 | 90 | MIN_PODS= getenv('MIN_PODS', 2) |
91 | 91 |
|
92 | | -# storage pricing, i.e. https://aws.amazon.com/ebs/pricing/ |
93 | | -COST_EBS = float(getenv('COST_EBS', 0.119)) # GB per month |
| 92 | +# storage pricing, i.e. https://aws.amazon.com/ebs/pricing/ (e.g. Europe - Franfurt) |
| 93 | +COST_EBS = float(getenv('COST_EBS', 0.0952)) # GB per month |
| 94 | +COST_IOPS = float(getenv('COST_IOPS', 0.006)) # IOPS per month above 3000 baseline |
| 95 | +COST_THROUGHPUT = float(getenv('COST_THROUGHPUT', 0.0476)) # MB/s per month above 125 MB/s baseline |
94 | 96 |
|
95 | 97 | # compute costs, i.e. https://www.ec2instances.info/?region=eu-central-1&selected=m5.2xlarge |
96 | 98 | COST_CORE = 30.5 * 24 * float(getenv('COST_CORE', 0.0575)) # Core per hour m5.2xlarge / 8. |
@@ -308,6 +310,8 @@ def index(): |
308 | 310 | 'pgui_link': '', |
309 | 311 | 'static_network_whitelist': {}, |
310 | 312 | 'cost_ebs': COST_EBS, |
| 313 | + 'cost_iops': COST_IOPS, |
| 314 | + 'cost_throughput': COST_THROUGHPUT, |
311 | 315 | 'cost_core': COST_CORE, |
312 | 316 | 'cost_memory': COST_MEMORY, |
313 | 317 | 'min_pods': MIN_PODS |
@@ -487,6 +491,8 @@ def get_postgresqls(): |
487 | 491 | 'cpu': spec.get('resources', {}).get('requests', {}).get('cpu', 0), |
488 | 492 | 'cpu_limit': spec.get('resources', {}).get('limits', {}).get('cpu', 0), |
489 | 493 | 'volume_size': spec.get('volume', {}).get('size', 0), |
| 494 | + 'iops': spec.get('volume', {}).get('iops', 3000), |
| 495 | + 'throughput': spec.get('volume', {}).get('throughput', 125), |
490 | 496 | 'team': ( |
491 | 497 | spec.get('teamId') or |
492 | 498 | metadata.get('labels', {}).get('team', '') |
@@ -614,6 +620,28 @@ def update_postgresql(namespace: str, cluster: str): |
614 | 620 |
|
615 | 621 | spec['volume'] = {'size': size} |
616 | 622 |
|
| 623 | + if ( |
| 624 | + 'volume' in postgresql['spec'] |
| 625 | + and 'iops' in postgresql['spec']['volume'] |
| 626 | + and postgresql['spec']['volume']['iops'] != None |
| 627 | + ): |
| 628 | + iops = int(postgresql['spec']['volume']['iops']) |
| 629 | + if not 'volume' in spec: |
| 630 | + spec['volume'] = {} |
| 631 | + |
| 632 | + spec['volume']['iops'] = iops |
| 633 | + |
| 634 | + if ( |
| 635 | + 'volume' in postgresql['spec'] |
| 636 | + and 'throughput' in postgresql['spec']['volume'] |
| 637 | + and postgresql['spec']['volume']['throughput'] != None |
| 638 | + ): |
| 639 | + throughput = int(postgresql['spec']['volume']['throughput']) |
| 640 | + if not 'volume' in spec: |
| 641 | + spec['volume'] = {} |
| 642 | + |
| 643 | + spec['volume']['throughput'] = throughput |
| 644 | + |
617 | 645 | if 'enableConnectionPooler' in postgresql['spec']: |
618 | 646 | cp = postgresql['spec']['enableConnectionPooler'] |
619 | 647 | if not cp: |
@@ -758,6 +786,27 @@ def update_postgresql(namespace: str, cluster: str): |
758 | 786 | owner_username=owner_username, |
759 | 787 | ) |
760 | 788 |
|
| 789 | + resource_types = ["cpu","memory"] |
| 790 | + resource_constraints = ["requests","limits"] |
| 791 | + if "resources" in postgresql["spec"]: |
| 792 | + spec["resources"] = {} |
| 793 | + |
| 794 | + res = postgresql["spec"]["resources"] |
| 795 | + for rt in resource_types: |
| 796 | + for rc in resource_constraints: |
| 797 | + if rc in res: |
| 798 | + if rt in res[rc]: |
| 799 | + if not rc in spec["resources"]: |
| 800 | + spec["resources"][rc] = {} |
| 801 | + spec["resources"][rc][rt] = res[rc][rt] |
| 802 | + |
| 803 | + if "postgresql" in postgresql["spec"]: |
| 804 | + if "version" in postgresql["spec"]["postgresql"]: |
| 805 | + if "postgresql" not in spec: |
| 806 | + spec["postgresql"]={} |
| 807 | + |
| 808 | + spec["postgresql"]["version"] = postgresql["spec"]["postgresql"]["version"] |
| 809 | + |
761 | 810 | o['spec'].update(spec) |
762 | 811 |
|
763 | 812 | apply_postgresql(get_cluster(), namespace, cluster, o) |
|
0 commit comments