infracost: Infracost uses Premium disk for AKS even though it's not available for given VM family
Hi,
It looks like Infracost makes invalid assumptions regarding OS disks provisioned for AKS.
Infracost version: v0.10.19
Steps to reproduce:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.0.0"
}
}
}
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
skip_provider_registration = true
}
# Create a resource group
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_kubernetes_cluster" "example" {
name = "example-aks1"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
dns_prefix = "exampleaks1"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}
identity {
type = "SystemAssigned"
}
tags = {
Environment = "Production"
}
}
Run infracost breakdown --path .
Result:
Expected result
Standard_D2_v2
in Azure doesn’t support Premium SSD disks. Estimation value should be ~108.88 USD
EDIT: I checked that VM size from both Terraform and Azure Portal and it seems, that it actually creates a Standard HDD disk.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (13 by maintainers)
Commits related to this issue
- added check for AKS instanceType #2407 — committed to varshneydevansh/infracost by varshneydevansh a year ago
- Revert "added check for AKS instanceType #2407" This reverts commit e52558140d1dc11ccdc4ed6c6d602181e1880ba9. — committed to varshneydevansh/infracost by varshneydevansh a year ago
- added check for AKS instanceType infracost#2407 — committed to varshneydevansh/infracost by varshneydevansh a year ago
- fix(azure): set correct OS disks for AKS node group instance types #2407 (#2547) * updated check for OS disks provisioned for AKS * added a test case for a non-premium instance * chore: update ... — committed to infracost/infracost by varshneydevansh a year ago
@kamil-mrzyglod this is now released in v0.10.25. Thanks @varshneydevansh for your contribution!
@varshneydevansh I checked the Azure APIs and these are the subfamily of instances that default to the premium storage:
So I think we can just add a check for
DS
,GS
, andM
prefixes for now, and if we find this changes more in the future we can introduce something like @kamil-mrzyglod suggested. Maybe a function like this would work?Let me know what you think.
From what I can tell AKS nodes defined in Terraform always use LRS type storage.
@varshneydevansh thank you! Yes please create a separate PR 🙏.
I’m doing a little more investigation into your other questions and will get back to you in the next day when I’ve had a chance to look.
I don’t think we have to worry about this just now.
Maybe something like this could work and be consistent with the naming conventions here. This makes sure we only search for the
s
in the part of the instance type that includes the “Additive features”.If I can suggest a solution (or something worth considering) - in my own tool for cost calculation, when challenged with that topic, I used VM capabilities API (see https://github.com/TheCloudTheory/arm-estimator/blob/main/arm-estimator/ResourceManager/CapabilitiesCache.cs). It’s much safer solution as you can ask Azure Resource Manager to tell you which VM families support Premium disks.
Thanks for the research @varshneydevansh! Looking at https://learn.microsoft.com/en-us/azure/virtual-machines/ I agree that the
s
means it uses a premium disk.I don’t think
if strings.Contains(instanceType, "s") {
is quite safe enough though since the instance type might contain another lowercases
. I suggest parsing the instance type using a regex to extract the “Additive Features” part of the instance type and see if it contains an s.@varshneydevansh, yes this issue is still pending.
We will probably need to update somewhere here to use different disk types depending on the instance type.