(clusterConfig *clusterconfig.Config, awsClient *aws.Client, disallowPrompt bool)
| 162 | } |
| 163 | |
| 164 | func confirmInstallClusterConfig(clusterConfig *clusterconfig.Config, awsClient *aws.Client, disallowPrompt bool) { |
| 165 | eksPrice := aws.EKSPrices[clusterConfig.Region] |
| 166 | operatorInstancePrice := aws.InstanceMetadatas[clusterConfig.Region]["t3.medium"].Price |
| 167 | prometheusInstancePrice := aws.InstanceMetadatas[clusterConfig.Region][clusterConfig.PrometheusInstanceType].Price |
| 168 | operatorEBSPrice := aws.EBSMetadatas[clusterConfig.Region]["gp3"].PriceGB * 20 / 30 / 24 |
| 169 | prometheusEBSPrice := aws.EBSMetadatas[clusterConfig.Region]["gp3"].PriceGB * 20 / 30 / 24 |
| 170 | metricsEBSPrice := aws.EBSMetadatas[clusterConfig.Region]["gp2"].PriceGB * (40 + 2) / 30 / 24 |
| 171 | nlbPrice := aws.NLBMetadatas[clusterConfig.Region].Price |
| 172 | elbPrice := aws.ELBMetadatas[clusterConfig.Region].Price |
| 173 | natUnitPrice := aws.NATMetadatas[clusterConfig.Region].Price |
| 174 | |
| 175 | var loadBalancersPrice float64 |
| 176 | usesELBForAPILoadBalancer := clusterConfig.APILoadBalancerType == clusterconfig.ELBLoadBalancerType |
| 177 | if usesELBForAPILoadBalancer { |
| 178 | loadBalancersPrice = nlbPrice + elbPrice |
| 179 | } else { |
| 180 | loadBalancersPrice = 2 * nlbPrice |
| 181 | } |
| 182 | |
| 183 | var natTotalPrice float64 |
| 184 | if clusterConfig.NATGateway == clusterconfig.SingleNATGateway { |
| 185 | natTotalPrice = natUnitPrice |
| 186 | } else if clusterConfig.NATGateway == clusterconfig.HighlyAvailableNATGateway { |
| 187 | natTotalPrice = natUnitPrice * float64(len(clusterConfig.AvailabilityZones)) |
| 188 | } |
| 189 | |
| 190 | headers := []table.Header{ |
| 191 | {Title: "aws resource"}, |
| 192 | {Title: "cost per hour"}, |
| 193 | } |
| 194 | |
| 195 | var rows [][]interface{} |
| 196 | rows = append(rows, []interface{}{"1 eks cluster", s.DollarsMaxPrecision(eksPrice)}) |
| 197 | |
| 198 | ngNameToSpotInstancesUsed := map[string]int{} |
| 199 | fixedPrice := eksPrice + 2*(operatorInstancePrice+operatorEBSPrice) + prometheusInstancePrice + prometheusEBSPrice + metricsEBSPrice + loadBalancersPrice + natTotalPrice |
| 200 | totalMinPrice := fixedPrice |
| 201 | totalMaxPrice := fixedPrice |
| 202 | for _, ng := range clusterConfig.NodeGroups { |
| 203 | apiInstancePrice := aws.InstanceMetadatas[clusterConfig.Region][ng.InstanceType].Price |
| 204 | apiEBSPrice := aws.EBSMetadatas[clusterConfig.Region][ng.InstanceVolumeType.String()].PriceGB * float64(ng.InstanceVolumeSize) / 30 / 24 |
| 205 | if ng.InstanceVolumeType == clusterconfig.IO1VolumeType && ng.InstanceVolumeIOPS != nil { |
| 206 | apiEBSPrice += aws.EBSMetadatas[clusterConfig.Region][ng.InstanceVolumeType.String()].PriceIOPS * float64(*ng.InstanceVolumeIOPS) / 30 / 24 |
| 207 | } |
| 208 | if ng.InstanceVolumeType == clusterconfig.GP3VolumeType && ng.InstanceVolumeIOPS != nil && ng.InstanceVolumeThroughput != nil { |
| 209 | apiEBSPrice += libmath.MaxFloat64(0, (aws.EBSMetadatas[clusterConfig.Region][ng.InstanceVolumeType.String()].PriceIOPS-3000)*float64(*ng.InstanceVolumeIOPS)/30/24) |
| 210 | apiEBSPrice += libmath.MaxFloat64(0, (aws.EBSMetadatas[clusterConfig.Region][ng.InstanceVolumeType.String()].PriceThroughput-125)*float64(*ng.InstanceVolumeThroughput)/30/24) |
| 211 | } |
| 212 | |
| 213 | totalMaxPrice += float64(ng.MaxInstances) * (apiInstancePrice + apiEBSPrice) |
| 214 | |
| 215 | workerInstanceStr := fmt.Sprintf("nodegroup %s: %d-%d %s instances", ng.Name, ng.MinInstances, ng.MaxInstances, ng.InstanceType) |
| 216 | if ng.MinInstances == ng.MaxInstances { |
| 217 | workerInstanceStr = fmt.Sprintf("nodegroup %s: %d %s %s", ng.Name, ng.MinInstances, ng.InstanceType, s.PluralS("instance", ng.MinInstances)) |
| 218 | } |
| 219 | |
| 220 | workerPriceStr := s.DollarsAndTenthsOfCents(apiInstancePrice+apiEBSPrice) + " each" |
| 221 | if ng.Spot { |
no test coverage detected