Skip to content

Commit 3f654b3

Browse files
authored
Adds internal instructions on how to use cost-estimation feature (#1860)
* Adds internal instructions on how to use cost-estimation feature * Apply suggestions from code review * Add some out of scope notes * ClusterClasses
1 parent 42a057a commit 3f654b3

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed

docs/cost-estimation.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Cost estimation
2+
3+
## Introduction
4+
5+
The cost estimation feature allows you to get a sense of how much a CAPI template's rendered output will cost. It is a best-effort estimate, and is not guaranteed to be accurate. It is based on the AWS Pricing API and is only available for AWS.
6+
7+
## Availability of this feature
8+
9+
Cost estimation was requested by a specific customer (IQT) and is not available for general use for now. These instructions are for internal use only.
10+
11+
## Enabling
12+
13+
We make some configuration changes to the `values` in the Weave Gitops Enterprise `HelmRelease`.
14+
15+
```yaml
16+
spec:
17+
values:
18+
config:
19+
costEstimation:
20+
# QueryString of filters to apply to cost estimation
21+
estimationFilter: "operatingSystem=Linux&tenancy=Dedicated&capacityStatus=UnusedCapacityReservation&operation=RunInstances"
22+
# the region used to fetch the pricing data, us-east-1 or ap-south-1 are publicly documented
23+
# as the only regions that support the pricing API
24+
apiRegion: us-east-1
25+
26+
extraEnvVars:
27+
- name: WEAVE_GITOPS_FEATURE_COST_ESTIMATION
28+
value: "true"
29+
30+
# If the cluster is not configured with IAM roles for service accounts, the following
31+
# line is required to provide the AWS credentials to the cost estimation service
32+
extraEnvVarsSecret: "aws-pricing-api-credentials"
33+
```
34+
35+
AWS credentials can be provided explicitly in the `extraEnvVarsSecret` or implicitly by using IAM roles for service accounts. If provided explicitly, the secret can be created with the following command:
36+
37+
```bash
38+
kubectl create secret generic aws-pricing-api-credentials \
39+
--namespace flux-system \
40+
--from-literal=AWS_ACCESS_KEY_ID='$MY_ACCESS_KEY' \
41+
--from-literal=AWS_SECRET_ACCESS_KEY='$MY_SECRET_KEY'
42+
```
43+
44+
### Permissions
45+
46+
The cost estimation service requires the `AWSPriceListServiceFullAccess` policy attached to the user or role used to access the pricing API.
47+
48+
## Estimation
49+
50+
The estimate is only based on the machine pool of the CAPI cluster, we take into account:
51+
52+
- The number of control planes
53+
- The number of worker nodes
54+
- The deployment region
55+
- Instance types
56+
57+
`instanceType` and `region` are automatically added to the estimation filters based on the values found in the template. Other filters should be added to get a more accurate estimate.
58+
59+
### Configuring the estimation filters
60+
61+
Providing additional filters based on your AWS environment will improve the accuracy of the estimate. For example in internal testing we have been using the following filters:
62+
63+
- `operatingSystem=Linux`
64+
- `tenancy=Dedicated`
65+
- `capacityStatus=UnusedCapacityReservation`
66+
- `operation=RunInstances`
67+
68+
Estimation filters are configured both via:
69+
70+
1. _(required)_ Global defaults in the `HelmRelease`:
71+
```yaml
72+
config:
73+
costEstimation:
74+
estimationFilter: "operatingSystem=Linux&tenancy=Dedicated&capacityStatus=UnusedCapacityReservation&operation=RunInstances"
75+
```
76+
2. _(optional)_ over-ride the global defaults on a per-template basis with the `weave.works/cost-estimation-filter` annotation on the `Cluster` resource in the template.
77+
```yaml
78+
apiVersion: cluster.x-k8s.io/v1beta1
79+
kind: Cluster
80+
metadata:
81+
name: "test-cluster"
82+
annotations:
83+
"templates.weave.works/estimation-filters": "tenancy=Shared"
84+
```
85+
86+
In both cases the filters should be expressed in the form of a query string.
87+
88+
## Hiding the cost estimation button on certain templates
89+
90+
You can disable the cost-estimation button from appearing on certain templates by adding the `templates.weave.works/cost-estimation-enabled: "false"` annotation to the `CAPITemplate`.
91+
92+
## Things that are out of scope
93+
94+
The following are out of scope for the cost estimation feature and may produce errors or inaccurate estimates if you try to estimate templates that use them:
95+
96+
- EKS clusters, managed and unmanaged
97+
- Auto Scaling groups of spot EC2 instances
98+
- CAPI ClusterClasses
99+
100+
Things that are ignored and are not included in the estimate:
101+
102+
- Other cluster resources like:
103+
- NAT gateways
104+
- Load balancers
105+
- Databases
106+
- Storage
107+
- etc
108+
- MachinePool `minSize` and `maxSize` are ignored, the estimate is based on the number of `replicas`
109+
110+
# Appendix: Available filters
111+
112+
This is a list of the available filters.
113+
114+
- instanceCapacityMetal
115+
- volumeType
116+
- maxIopsvolume
117+
- instance
118+
- classicnetworkingsupport
119+
- instanceCapacity10xlarge
120+
- fromRegionCode
121+
- locationType
122+
- toLocationType
123+
- instanceFamily
124+
- operatingSystem
125+
- toRegionCode
126+
- clockSpeed
127+
- LeaseContractLength
128+
- ecu
129+
- networkPerformance
130+
- instanceCapacity8xlarge
131+
- group
132+
- maxThroughputvolume
133+
- gpuMemory
134+
- ebsOptimized
135+
- vpcnetworkingsupport
136+
- maxVolumeSize
137+
- gpu
138+
- intelAvxAvailable
139+
- processorFeatures
140+
- instanceCapacity4xlarge
141+
- servicecode
142+
- groupDescription
143+
- elasticGraphicsType
144+
- volumeApiName
145+
- processorArchitecture
146+
- physicalCores
147+
- fromLocation
148+
- snapshotarchivefeetype
149+
- marketoption
150+
- availabilityzone
151+
- productFamily
152+
- fromLocationType
153+
- enhancedNetworkingSupported
154+
- intelTurboAvailable
155+
- memory
156+
- dedicatedEbsThroughput
157+
- vcpu
158+
- OfferingClass
159+
- instanceCapacityLarge
160+
- capacitystatus
161+
- termType
162+
- storage
163+
- toLocation
164+
- intelAvx2Available
165+
- storageMedia
166+
- regionCode
167+
- physicalProcessor
168+
- provisioned
169+
- servicename
170+
- PurchaseOption
171+
- instancesku
172+
- productType
173+
- instanceCapacity18xlarge
174+
- instanceType
175+
- tenancy
176+
- usagetype
177+
- normalizationSizeFactor
178+
- instanceCapacity16xlarge
179+
- instanceCapacity2xlarge
180+
- maxIopsBurstPerformance
181+
- instanceCapacity12xlarge
182+
- instanceCapacity32xlarge
183+
- instanceCapacityXlarge
184+
- licenseModel
185+
- currentGeneration
186+
- preInstalledSw
187+
- transferType
188+
- location
189+
- instanceCapacity24xlarge
190+
- instanceCapacity9xlarge
191+
- instanceCapacityMedium
192+
- operation
193+
- resourceType

0 commit comments

Comments
 (0)