Skip to content

Commit

Permalink
new: Represent region-specific pricing when configuring LKE Node Pools (
Browse files Browse the repository at this point in the history
#5065)

* Add support for region-specific pricing

* fix grammar
  • Loading branch information
lgarber-akamai authored Dec 9, 2024
1 parent e87641d commit ae0f3f3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,17 @@ export default Component.extend(ClusterDriver, {
errors: [],
step: 2,
regions: responses.regions.data.filter((region) => (region.status === 'ok' && region.capabilities.includes('Kubernetes'))),
nodeTypes: responses.nodeTypes.data.filter((type) => (['standard', 'highmem', 'dedicated'].includes(type.class))),
nodeTypes: responses.nodeTypes.data.filter(
(type) => (['standard', 'highmem', 'dedicated'].includes(type.class))
).map((type) => {
// We need to set default values for effective prices
return {
...type,
isException: false,
effectiveHourly: type.price.hourly,
effectiveMonthly: type.price.monthly
}
}),
k8sVersions: responses.k8sVersions.data,
});

Expand Down Expand Up @@ -239,8 +249,9 @@ export default Component.extend(ClusterDriver, {
const selectedNodePoolList = get(this, 'selectedNodePoolList');
const nodePools = selectedNodePoolList.map((np) => {
return `${ np.id }=${ np.count }`
})
});

set(this, 'configHasRegionException', selectedNodePoolList.filter((type) => type.isException).length > 0)
set(this, 'cluster.lkeEngineConfig.nodePools', nodePools);
}),

Expand All @@ -249,6 +260,28 @@ export default Component.extend(ClusterDriver, {
this.prefillSelectedNodePoolList();
}),

updateEffectiveTypePrices: observer('cluster.lkeEngineConfig.region', function() {
// We need special handling for regional price exceptions
const nodeTypes = this.nodeTypes.map((type) => {
let override = undefined;

if (type['region_prices'] !== undefined) {
override = type.region_prices.find((override) => override.id === this.cluster.lkeEngineConfig.region);
}

const isException = override !== undefined;

return {
...type,
isException,
effectiveHourly: isException ? override.hourly : type.price.hourly,
effectiveMonthly: isException ? override.monthly : type.price.monthly
}
});

set(this, 'nodeTypes', nodeTypes);
}),

// Any computed properties or custom logic can go here

// for region choises
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@
<div class="acc-label pb-15">
{{t "clusterNew.linodelke.nodePoolConfig.monthly"}}:
</div>
{{format-number this.selectedNodePoolObj.price.monthly style='currency' currency='USD' allowEmpty=true}}
{{format-number this.selectedNodePoolObj.effectiveMonthly style='currency' currency='USD' allowEmpty=true}}
</div>
<div class="col span-1">
<div class="acc-label pb-15">
{{t "clusterNew.linodelke.nodePoolConfig.hourly"}}:
</div>
{{format-number this.selectedNodePoolObj.price.hourly style='currency' currency='USD' allowEmpty=true}}
{{format-number this.selectedNodePoolObj.effectiveHourly style='currency' currency='USD' allowEmpty=true}}
</div>
<div class="col span-1">
<div class="acc-label pb-15">
Expand Down Expand Up @@ -255,6 +255,13 @@
</h2>
</div>
</div>
{{# if this.configHasRegionException}}
{{banner-message
icon="icon-alert"
color="bg-warning mb-10"
message=(t "clusterNew.linodelke.selectedNodePoolType.regionPriceWarning")
}}
{{/if}}
{{#sortable-table
classNames="grid fixed mb-0 sortable-table"
sortBy=sortBy
Expand All @@ -274,10 +281,10 @@
{{member.label}}
</td>
<td data-title="{{dt.priceMonthly}}">
{{format-number member.price.monthly style='currency' currency='USD' allowEmpty=true}}
{{format-number member.effectiveMonthly style='currency' currency='USD' allowEmpty=true}}
</td>
<td data-title="{{dt.priceHourly}}">
{{format-number member.price.hourly style='currency' currency='USD' allowEmpty=true}}
{{format-number member.effectiveHourly style='currency' currency='USD' allowEmpty=true}}
</td>
<td data-title="{{dt.ram}}">
{{member.memoryGb}} {{t "generic.gigabyte"}}
Expand Down
5 changes: 3 additions & 2 deletions translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3347,7 +3347,7 @@ clusterNew:
fleet: Fleet Agent Configuration
accordionDetail:
cluster: Customize scheduling fields and resource limits for the Rancher cluster agent
fleet: Customize scheduling fields and resource limits for the Rancher fleet agent
fleet: Customize scheduling fields and resource limits for the Rancher fleet agent
banners:
advanced: These are advanced configuration options. Generally, they should be left as-is.
resourceRequests: Pod Requests and Limits do not have a default configuration.
Expand Down Expand Up @@ -3621,7 +3621,7 @@ clusterNew:
parsedDockerBridgeCidr: Docker bridge address can not overlap with the selected Virtual Network or the Kubernetes service address range
parsedServiceCidr: Kubernetes service address range must fall within the selected Virtual Network range.
serviceCidr: Kubernetes service address range must be valid CIDR format.
nodeResourceGroup:
nodeResourceGroup:
length: "{key} name cannot exceed 80 characters."
chars: "{key} name may only consist of underscores, periods, hyphens, parentheses, and letters or digits."
periodEnd: "{key} name cannot end with a period."
Expand Down Expand Up @@ -4396,6 +4396,7 @@ clusterNew:
selectedNodePoolType:
label: Select type
placeholder: Select a node pool type
regionPriceWarning: One or more node pools in this configuration are subject to region-specific pricing. These prices are reflected in the displayed configuration below.
shortLabel: Linode LKE
tags:
label: Tags
Expand Down

0 comments on commit ae0f3f3

Please sign in to comment.