diff --git a/ui/app/src/edit.tag.pug b/ui/app/src/edit.tag.pug index bb536a8e4..ddcaa4653 100644 --- a/ui/app/src/edit.tag.pug +++ b/ui/app/src/edit.tag.pug @@ -139,6 +139,9 @@ edit o.spec.enableMasterLoadBalancer = i.spec.enableMasterLoadBalancer || false o.spec.enableReplicaLoadBalancer = i.spec.enableReplicaLoadBalancer || false o.spec.enableConnectionPooler = i.spec.enableConnectionPooler || false + o.spec.enableReplicaConnectionPooler = i.spec.enableReplicaConnectionPooler || false + o.spec.enableMasterPoolerLoadBalancer = i.spec.enableMasterPoolerLoadBalancer || false + o.spec.enableReplicaPoolerLoadBalancer = i.spec.enableReplicaPoolerLoadBalancer || false o.spec.volume = { size: i.spec.volume.size, diff --git a/ui/app/src/new.tag.pug b/ui/app/src/new.tag.pug index 02955602b..c066ad4f4 100644 --- a/ui/app/src/new.tag.pug +++ b/ui/app/src/new.tag.pug @@ -216,40 +216,73 @@ new ) tr(if='{ [undefined, true].includes(config.master_load_balancer_visible) }') - td Master load balancer + td Enable load balancer td - label - input( - type='checkbox' - value='{ enableMasterLoadBalancer }' - onchange='{ toggleEnableMasterLoadBalancer }' - ) - | - | Enable master ELB + ul.ips + li + label + input( + type='checkbox' + value='{ enableMasterLoadBalancer }' + onchange='{ toggleEnableMasterLoadBalancer }' + ) + | + | Master + li(if='{ [undefined, true].includes(config.replica_load_balancer_visible) && instanceCount > 1 }') + label + input( + type='checkbox' + value='{ enableReplicaLoadBalancer }' + onchange='{ toggleEnableReplicaLoadBalancer }' + ) + | + | Replica - tr(if='{ [undefined, true].includes(config.replica_load_balancer_visible) }') - td Replica load balancer + tr(if='{ [undefined, true].includes(config.connection_pooler_visible) }') + td Enable connection pooler td - label - input( - type='checkbox' - value='{ enableReplicaLoadBalancer }' - onchange='{ toggleEnableReplicaLoadBalancer }' - ) - | - | Enable replica ELB + ul.ips + li + label + input( + type='checkbox' + value='{ enableConnectionPooler }' + onchange='{ toggleEnableConnectionPooler }' + ) + | + | Master + li(if='{ [undefined, true].includes(config.replica_connection_pooler_visible) && instanceCount > 1 }') + label + input( + type='checkbox' + value='{ enableReplicaConnectionPooler }' + onchange='{ toggleEnableReplicaConnectionPooler }' + ) + | + | Replica - tr - td Enable Connection Pool + tr(if='{ [undefined, true].includes(config.master_pooler_load_balancer_visible) }') + td Enable connection pooler load balancer td - label - input( - type='checkbox' - value='{ enableConnectionPooler }' - onchange='{ toggleEnableConnectionPooler }' - ) - | - | Enable Connection Pool (using PGBouncer) + ul.ips + li + label + input( + type='checkbox' + value='{ enableMasterPoolerLoadBalancer }' + onchange='{ toggleEnableMasterPoolerLoadBalancer }' + ) + | + | Master + li(if='{ [undefined, true].includes(config.replica_pooler_load_balancer_visible) && instanceCount > 1 }') + label + input( + type='checkbox' + value='{ enableReplicaPoolerLoadBalancer }' + onchange='{ toggleEnableReplicaPoolerLoadBalancer }' + ) + | + | Replica tr td Volume size @@ -267,7 +300,7 @@ new .input-group-addon .input-units Gi tr - td + td td Specify Iops and Throughput only if you need more than the default 3000 Iops and 125Mb/s EBS provides. tr @@ -539,6 +572,15 @@ new {{#if enableConnectionPooler}} enableConnectionPooler: true {{/if}} + {{#if enableReplicaConnectionPooler}} + enableReplicaConnectionPooler: true + {{/if}} + {{#if enableMasterPoolerLoadBalancer}} + enableMasterPoolerLoadBalancer: true + {{/if}} + {{#if enableReplicaPoolerLoadBalancer}} + enableReplicaPoolerLoadBalancer: true + {{/if}} volume: size: "{{ volumeSize }}Gi"{{#if iops}} iops: {{ iops }}{{/if}}{{#if throughput}} @@ -592,6 +634,9 @@ new enableMasterLoadBalancer: this.enableMasterLoadBalancer, enableReplicaLoadBalancer: this.enableReplicaLoadBalancer, enableConnectionPooler: this.enableConnectionPooler, + enableReplicaConnectionPooler: this.enableReplicaConnectionPooler, + enableMasterPoolerLoadBalancer: this.enableMasterPoolerLoadBalancer, + enableReplicaPoolerLoadBalancer: this.enableReplicaPoolerLoadBalancer, volumeSize: this.volumeSize, iops: this.iops, throughput: this.throughput, @@ -655,6 +700,18 @@ new this.enableConnectionPooler = !this.enableConnectionPooler } + this.toggleEnableReplicaConnectionPooler = e => { + this.enableReplicaConnectionPooler = !this.enableReplicaConnectionPooler + } + + this.toggleEnableMasterPoolerLoadBalancer = e => { + this.enableMasterPoolerLoadBalancer = !this.enableMasterPoolerLoadBalancer + } + + this.toggleEnableReplicaPoolerLoadBalancer = e => { + this.enableReplicaPoolerLoadBalancer = !this.enableReplicaPoolerLoadBalancer + } + this.volumeChange = e => { this.volumeSize = +e.target.value } @@ -692,6 +749,11 @@ new this.instanceCountChange = e => { this.instanceCount = +e.target.value + if (this.instanceCount < 2) { + this.enableReplicaLoadBalancer = false + this.enableReplicaConnectionPooler = false + this.enableReplicaPoolerLoadBalancer = false + } } this.checkClusterExists = () => ( @@ -957,6 +1019,9 @@ new this.enableMasterLoadBalancer = false this.enableReplicaLoadBalancer = false this.enableConnectionPooler = false + this.enableReplicaConnectionPooler = false + this.enableMasterPoolerLoadBalancer = false + this.enableReplicaPoolerLoadBalancer = false this.postgresqlVersion = this.postgresqlVersion = ( this.config.postgresql_versions[0] diff --git a/ui/app/src/postgresql.tag.pug b/ui/app/src/postgresql.tag.pug index c557e4da8..f1b15ca81 100644 --- a/ui/app/src/postgresql.tag.pug +++ b/ui/app/src/postgresql.tag.pug @@ -168,11 +168,13 @@ postgresql this.progress.dnsName = data.metadata.name + '.' + data.metadata.namespace } - jQuery.get('/pooler/' + this.cluster_path).done(data => { - this.progress.pooler = {"url": ""} - this.update() - }) - + if (this.progress.poolerEnabled == true) { + jQuery.get('/pooler/' + this.cluster_path).done(data => { + this.progress.pooler = {"url": ""} + this.update() + }) + } + this.update() }) }) diff --git a/ui/app/src/postgresqls.tag.pug b/ui/app/src/postgresqls.tag.pug index 742bb2968..6b60b9f8a 100644 --- a/ui/app/src/postgresqls.tag.pug +++ b/ui/app/src/postgresqls.tag.pug @@ -68,6 +68,8 @@ postgresqls | IOPS (-3000 baseline): 0.006$ br | Throughput (-125 baseline): 0.0476$ + br + | 1 ELB: 21.96$ th(stlye='width: 120px') tbody @@ -87,7 +89,7 @@ postgresqls td { volume_size } td { iops } td { throughput } - td { calcCosts(nodes, cpu, memory, volume_size, iops, throughput) }$ + td { calcCosts(nodes, cpu, memory, volume_size, iops, throughput, num_elb) }$ td @@ -167,7 +169,9 @@ postgresqls | IOPS (-3000 baseline): 0.006$ br | Throughput (-125 baseline): 0.0476$ - th(stlye='width: 120px') + br + | 1 ELB: 21.96$ + th(style='width: 120px') tbody tr( @@ -188,7 +192,7 @@ postgresqls td { volume_size } td { iops } td { throughput } - td { calcCosts(nodes, cpu, memory, volume_size, iops, throughput) }$ + td { calcCosts(nodes, cpu, memory, volume_size, iops, throughput, num_elb) }$ td @@ -263,10 +267,11 @@ postgresqls + '/' + encodeURI(cluster.name) ) - const calcCosts = this.calcCosts = (nodes, cpu, memory, disk, iops, throughput) => { + const calcCosts = this.calcCosts = (nodes, cpu, memory, disk, iops, throughput, num_elb) => { podcount = Math.max(nodes, opts.config.min_pods) corecost = toCores(cpu) * opts.config.cost_core * 30.5 * 24 memorycost = toMemory(memory) * opts.config.cost_memory * 30.5 * 24 + elbcost = num_elb * opts.config.cost_elb * 30.5 * 24 diskcost = toDisk(disk) * opts.config.cost_ebs iopscost = 0 if (iops !== undefined && iops > opts.config.free_iops) { @@ -283,7 +288,7 @@ postgresqls throughputcost = (throughput - opts.config.free_throughput) * opts.config.cost_throughput } - costs = podcount * (Math.max(corecost, memorycost) + diskcost + iopscost + throughputcost) + costs = podcount * (Math.max(corecost, memorycost) + diskcost + iopscost + throughputcost) + elbcost return costs.toFixed(2) } diff --git a/ui/operator_ui/main.py b/ui/operator_ui/main.py index f3854628a..72fb7d4e6 100644 --- a/ui/operator_ui/main.py +++ b/ui/operator_ui/main.py @@ -101,6 +101,7 @@ COST_THROUGHPUT = float(getenv('COST_THROUGHPUT', 0.0476)) # MB/s per month abo # compute costs, i.e. https://www.ec2instances.info/?region=eu-central-1&selected=m5.2xlarge COST_CORE = float(getenv('COST_CORE', 0.0575)) # Core per hour m5.2xlarge / 8. COST_MEMORY = float(getenv('COST_MEMORY', 0.014375)) # Memory GB m5.2xlarge / 32. +COST_ELB = float(getenv('COST_ELB', 0.03)) # per hour # maximum and limitation of IOPS and throughput FREE_IOPS = float(getenv('FREE_IOPS', 3000)) @@ -334,6 +335,7 @@ DEFAULT_UI_CONFIG = { 'cost_throughput': COST_THROUGHPUT, 'cost_core': COST_CORE, 'cost_memory': COST_MEMORY, + 'cost_elb': COST_ELB, 'min_pods': MIN_PODS, 'free_iops': FREE_IOPS, 'free_throughput': FREE_THROUGHPUT, @@ -523,6 +525,8 @@ def get_postgresqls(): 'namespaced_name': namespace + '/' + name, 'full_name': namespace + '/' + name + ('/' + uid if uid else ''), 'status': status, + 'num_elb': spec.get('enableMasterLoadBalancer', 0) + spec.get('enableReplicaLoadBalancer', 0) + \ + spec.get('enableMasterPoolerLoadBalancer', 0) + spec.get('enableReplicaPoolerLoadBalancer', 0), } for cluster in these( read_postgresqls( @@ -662,49 +666,20 @@ def update_postgresql(namespace: str, cluster: str): spec['volume']['throughput'] = throughput - if 'enableConnectionPooler' in postgresql['spec']: - cp = postgresql['spec']['enableConnectionPooler'] - if not cp: - if 'enableConnectionPooler' in o['spec']: - del o['spec']['enableConnectionPooler'] - else: - spec['enableConnectionPooler'] = True - else: - if 'enableConnectionPooler' in o['spec']: - del o['spec']['enableConnectionPooler'] + additional_specs = ['enableMasterLoadBalancer', + 'enableReplicaLoadBalancer', + 'enableConnectionPooler', + 'enableReplicaConnectionPooler', + 'enableMasterPoolerLoadBalancer', + 'enableReplicaPoolerLoadBalancer', + ] - if 'enableReplicaConnectionPooler' in postgresql['spec']: - cp = postgresql['spec']['enableReplicaConnectionPooler'] - if not cp: - if 'enableReplicaConnectionPooler' in o['spec']: - del o['spec']['enableReplicaConnectionPooler'] + for var in additional_specs: + if postgresql['spec'].get(var): + spec[var] = True else: - spec['enableReplicaConnectionPooler'] = True - else: - if 'enableReplicaConnectionPooler' in o['spec']: - del o['spec']['enableReplicaConnectionPooler'] - - if 'enableReplicaLoadBalancer' in postgresql['spec']: - rlb = postgresql['spec']['enableReplicaLoadBalancer'] - if not rlb: - if 'enableReplicaLoadBalancer' in o['spec']: - del o['spec']['enableReplicaLoadBalancer'] - else: - spec['enableReplicaLoadBalancer'] = True - else: - if 'enableReplicaLoadBalancer' in o['spec']: - del o['spec']['enableReplicaLoadBalancer'] - - if 'enableMasterLoadBalancer' in postgresql['spec']: - rlb = postgresql['spec']['enableMasterLoadBalancer'] - if not rlb: - if 'enableMasterLoadBalancer' in o['spec']: - del o['spec']['enableMasterLoadBalancer'] - else: - spec['enableMasterLoadBalancer'] = True - else: - if 'enableMasterLoadBalancer' in o['spec']: - del o['spec']['enableMasterLoadBalancer'] + if var in o['spec']: + del o['spec'][var] if 'users' in postgresql['spec']: spec['users'] = postgresql['spec']['users']