Skip to content

Add WithSystemNodePool() to customize AKS system node pool VM size#16312

Merged
mitchdenny merged 4 commits intomainfrom
fix/aks-system-node-pool-16283
Apr 20, 2026
Merged

Add WithSystemNodePool() to customize AKS system node pool VM size#16312
mitchdenny merged 4 commits intomainfrom
fix/aks-system-node-pool-16283

Conversation

@mitchdenny
Copy link
Copy Markdown
Member

Description

Adds AddSystemNodePool() extension method to allow customizing the AKS system node pool VM size and autoscaling configuration.

Problem: The system node pool VM size was hardcoded to Standard_D2s_v5 with no way to override it. Users whose subscriptions don't allow that SKU in their target region had no workaround besides deploying to a different region.

Solution: AddSystemNodePool(vmSize, minCount, maxCount) replaces the default system pool configuration. It mirrors the existing AddNodePool() API but always targets the system pool (named "system", mode System). Returns the environment builder for chaining since users don't schedule workloads on system pools.

var aks = builder.AddAzureKubernetesEnvironment("aks")
    .AddSystemNodePool("Standard_B2s");

Fixes #16283

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Fixes #16283 - The AKS system node pool VM size was hardcoded to
Standard_D2s_v5 with no override. Users whose subscriptions don't
allow that SKU in their target region had no workaround.

Added AddSystemNodePool() extension method on
IResourceBuilder<AzureKubernetesEnvironmentResource> that replaces
the default system pool configuration. Parameters mirror AddNodePool()
(vmSize, minCount, maxCount) but always target the system pool.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 19, 2026 23:52
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 19, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16312

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16312"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new fluent extension method on AzureKubernetesEnvironmentResource to let callers override the AKS system node pool VM size (and autoscaling bounds), addressing deployments that fail when the default SKU isn’t available in a given subscription/region.

Changes:

  • Introduces AddSystemNodePool(vmSize, minCount, maxCount) to replace the default system pool configuration.
  • Adds unit tests validating replacement behavior, chaining with AddNodePool, and Bicep output.
  • Adds a new Verify snapshot asserting the customized VM size is emitted in generated Bicep.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentExtensions.cs Adds AddSystemNodePool API that removes existing system pool configs and inserts a customized system pool.
tests/Aspire.Hosting.Azure.Kubernetes.Tests/AzureKubernetesEnvironmentExtensionsTests.cs Adds coverage for default replacement, multiple calls, chaining, and Bicep generation.
tests/Aspire.Hosting.Azure.Kubernetes.Tests/Snapshots/AzureKubernetesEnvironmentExtensionsTests.AddSystemNodePool_BicepReflectsCustomVmSize.verified.bicep New snapshot verifying Bicep reflects the custom system pool VM size.

Comment on lines +223 to +224
ArgumentOutOfRangeException.ThrowIfNegative(minCount);
ArgumentOutOfRangeException.ThrowIfNegative(maxCount);
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddSystemNodePool currently allows minCount (and therefore count) to be 0, because it only checks for negative values. AKS system node pools must have at least 1 node; generating Bicep with count: 0/minCount: 0 for mode: 'System' will fail deployment. Consider validating minCount >= 1 (and implicitly maxCount >= 1) and updating/adding a unit test to cover the invalid 0 case.

Suggested change
ArgumentOutOfRangeException.ThrowIfNegative(minCount);
ArgumentOutOfRangeException.ThrowIfNegative(maxCount);
ArgumentOutOfRangeException.ThrowIfLessThan(minCount, 1);
ArgumentOutOfRangeException.ThrowIfLessThan(maxCount, 1);

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,52 @@
@description('The location for the resource(s) to be deployed.')
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snapshot file appears to include a UTF-8 BOM / leading U+FEFF character before @description (visible as an extra character at the start of line 1). Other .verified.bicep snapshots in this test project don’t include it; please remove the BOM so the snapshot content/encoding is consistent and avoids diff/test noise.

Suggested change
@description('The location for the resource(s) to be deployed.')
@description('The location for the resource(s) to be deployed.')

Copilot uses AI. Check for mistakes.
@mitchdenny
Copy link
Copy Markdown
Member Author

See also #16313 which is complementary — it adds VM size discovery to help users find available SKUs in their subscription/region.

…shot

System node pools require at least 1 node. Changed validation from
ThrowIfNegative to ThrowIfLessThan(1) for both minCount and maxCount.
Added test for the zero minCount rejection. Removed UTF-8 BOM from
the snapshot file for consistency with other snapshots.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentExtensions.cs Outdated
The With* prefix better reflects that this method configures/replaces
the existing system pool rather than adding a new one alongside it.
Consistent with other configuration methods like WithSubnet,
WithWorkloadIdentity, and WithContainerRegistry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mitchdenny
Copy link
Copy Markdown
Member Author

/deployment-test

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Deployment tests starting on PR #16312...

This will deploy to real Azure infrastructure. Results will be posted here when complete.

View workflow run

@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 20, 2026 03:17 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 20, 2026 03:17 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 20, 2026 03:17 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 20, 2026 03:17 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions github-actions Bot had a problem deploying to deployment-testing April 20, 2026 03:17 Failure
@github-actions github-actions Bot had a problem deploying to deployment-testing April 20, 2026 03:17 Failure
@github-actions github-actions Bot temporarily deployed to deployment-testing April 20, 2026 03:17 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

Deployment E2E Tests failed — 25 passed, 6 failed, 0 cancelled

View test results and recordings

View workflow run

Test Result Recording
Deployment.EndToEnd-AcaCompactNamingDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetKeyVaultInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptVnetSqlServerInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetSqlServerConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-TypeScriptExpressDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureServiceBusDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-NspStorageKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobConnectivityDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureEventHubsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureStorageDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AuthenticationTests ✅ Passed
Deployment.EndToEnd-AzureAppConfigDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AppServiceReactDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaExistingRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaDeploymentErrorOutputTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AcaCustomRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureLogAnalyticsDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterWithRedisDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AksStarterDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureKeyVaultDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-VnetStorageBlobInfraDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-AzureContainerRegistryDeploymentTests ✅ Passed ▶️ View Recording
Deployment.EndToEnd-PythonFastApiDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-FoundryHostedAgentDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AcrPurgeTaskDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AcaCompactNamingUpgradeDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AcaManagedRedisDeploymentTests ❌ Failed ▶️ View Recording
Deployment.EndToEnd-AppServicePythonDeploymentTests ❌ Failed ▶️ View Recording

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mitchdenny mitchdenny changed the title Add AddSystemNodePool() to customize AKS system node pool VM size Add WithSystemNodePool() to customize AKS system node pool VM size Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 72 recordings uploaded (commit b9ccb6a)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24647795995

@mitchdenny mitchdenny merged commit 53c95ee into main Apr 20, 2026
560 of 565 checks passed
@github-actions github-actions Bot added this to the 13.3 milestone Apr 20, 2026
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.

AKS: System node pool VM size is hardcoded to Standard_D2s_v5 with no override

3 participants