Skip to content

Comments

feat: Add VMSizeProperties support to disable SMT/hyperthreading#1419

Open
fabioaraujopt wants to merge 1 commit intoAzure:mainfrom
fabioaraujopt:feat/add-vmsizeproperties-smt-support
Open

feat: Add VMSizeProperties support to disable SMT/hyperthreading#1419
fabioaraujopt wants to merge 1 commit intoAzure:mainfrom
fabioaraujopt:feat/add-vmsizeproperties-smt-support

Conversation

@fabioaraujopt
Copy link

Summary

This PR adds support for Azure VM vCore Customization feature, allowing users to disable SMT (Simultaneous Multi-Threading, also known as hyperthreading) on AKS nodes provisioned by Karpenter.

Changes

  • API: Add VMSizeProperties field to AKSNodeClassSpec with vCPUsPerCore configuration
  • Validation: Add kubebuilder validation for vCPUsPerCore range (1-2)
  • VM Creation: Update newVMObject to apply vmSizeProperties to hardwareProfile
  • Tests: Add comprehensive unit tests for API validation and VM creation
  • CRDs: Generate updated CRDs with new field

Use Cases

This feature is particularly useful for:

  • CAE Workloads: Computer-Aided Engineering workloads requiring consistent performance without SMT overhead
  • Security Hardening: Disabling SMT to mitigate certain CPU vulnerabilities (Spectre, Meltdown variants)
  • Performance Optimization: Workloads that benefit from dedicated physical cores

Example Usage

apiVersion: karpenter.azure.com/v1beta1
kind: AKSNodeClass
metadata:
  name: smt-disabled
spec:
  imageFamily: AzureLinux
  vmSizeProperties:
    vCPUsPerCore: 1  # 1 = SMT disabled, 2 = SMT enabled (default)

Configuration Options

  • vCPUsPerCore: 1 - Disables hyperthreading (1 thread per physical core)
  • vCPUsPerCore: 2 - Enables hyperthreading (2 threads per physical core, default)
  • Omit field - Uses Azure default (hyperthreading enabled)

Requirements & Limitations

  • VM must support hyperthreading (2 threads per core)
  • Can only be set at VM creation time (not on running VMs)
  • Requires Azure API version 2021-07-01 or later
  • Only first-party Azure images supported (Windows Server, Ubuntu, Red Hat, SUSE, AzureLinux)

Testing

  • ✅ API validation tests for vCPUsPerCore range
  • ✅ Unit tests for convertVMSizeProperties function
  • ✅ CRD generation validated
  • ✅ All existing tests pass

Documentation

Related Azure documentation:

Related Issues

This addresses the feature gap identified between AWS and Azure Karpenter providers, where AWS EC2NodeClass supports SMT control via userData but Azure AKSNodeClass had no equivalent mechanism.


Checklist:

  • API changes documented
  • Tests added/updated
  • CRDs generated
  • Code follows project conventions
  • Commit message follows conventional commits

This PR adds support for Azure VM vCore Customization feature,
allowing users to disable SMT (Simultaneous Multi-Threading, also
known as hyperthreading) on AKS nodes provisioned by Karpenter.

Changes:
- Add VMSizeProperties field to AKSNodeClassSpec API
- Support vCPUsPerCore configuration (1=SMT disabled, 2=SMT enabled)
- Add validation for vCPUsPerCore range (1-2)
- Update VM creation to apply vmSizeProperties to hardwareProfile
- Add comprehensive unit tests for API validation
- Add tests for VM creation with vmSizeProperties
- Generate updated CRDs with new field

Use case:
This feature is particularly useful for:
- CAE (Computer-Aided Engineering) workloads requiring consistent
  performance without SMT overhead
- Security hardening by disabling SMT to mitigate certain CPU
  vulnerabilities
- Workloads that benefit from dedicated physical cores

Example usage:
```yaml
apiVersion: karpenter.azure.com/v1beta1
kind: AKSNodeClass
metadata:
  name: smt-disabled
spec:
  imageFamily: AzureLinux
  vmSizeProperties:
    vCPUsPerCore: 1  # Disables SMT
```

Requirements:
- VM must support hyperthreading (2 threads per core)
- Can only be set at VM creation time
- Requires Azure API version 2021-07-01 or later

Related documentation:
https://learn.microsoft.com/en-us/azure/virtual-machines/vm-customization

Fixes: Feature request for SMT control in Azure Karpenter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant