Make AKS node pool OS SKU configurable (support 'AzureLinux') in AddAzureKubernetesEnvironment
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
I deployed my app with AKS provisioned by Aspire (via `AddAzureKubernetesEnvironment`). My team wants to migrate node pools to Azure Linux 3.0, which requires setting the agent pool `osSKU` property to `'AzureLinux'` in the generated `aks.bicep`.
Today there is no public API to configure the node pool OS SKU, and the emitted agent pool profile in `ConfigureAksInfrastructure` never sets `OSSku`, so the property is absent from the generated Bicep. Manually editing the generated `aks.bicep` to add `osSKU: 'AzureLinux'` does not stick — every time we run `aspire deploy`, the Bicep is re-generated from the app model and our manual edit is lost.
This block migrating node pools to Azure Linux 3.0 without manual post-processing of the generated templates on every deploy.
### Describe the solution you'd like
Expose a way to configure the AKS node pool OS SKU through the Aspire app model so the value flows into the generated Bicep and survives `aspire deploy` re-generation.
Proposed approach:
- Add an `OsSku` property to `AksNodePoolConfig` (in `src/Aspire.Hosting.Azure.Kubernetes/AksNodePoolConfig.cs`).
- Surface it on the public API, e.g. an optional parameter on `AddNodePool` / `WithSystemNodePool`, or a dedicated `WithOSSku(...)` extension on the node pool builder.
- Wire the value into `ConfigureAksInfrastructure` when building `ManagedClusterAgentPoolProfile`, mapping to `ManagedClusterAgentPoolProfile.OSSku` (type `ContainerServiceOSSku`, which has an `AzureLinux` member in `Azure.Provisioning.ContainerService`). For example:
```csharp
var agentPool = new ManagedClusterAgentPoolProfile
{
Name = pool.Name,
VmSize = pool.VmSize,
// ...
OSType = ContainerServiceOSType.Linux,
OSSku = pool.OsSku, // e.g. ContainerServiceOSSku.AzureLinux
};
```
Open design questions:
- Should `AzureLinux` become the **default** OS SKU for emitted node pools, or remain **opt-in** (preserve today's AKS default and let users choose `AzureLinux`)? Changing the default is a behavior change for existing users.
- Preferred configuration surface: a new `osSku` parameter on `AddNodePool`/`WithSystemNodePool`, or a dedicated `WithOSSku(...)` extension?
Alternatives considered:
- Hand-editing the generated `aks.bicep` — rejected because `aspire deploy` regenerates it and overwrites the change.
### Additional context
Relevant code (no `OSSku` is set today on the agent pool profile):
https://github.com/microsoft/aspire/blob/main/src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentExtensions.cs#L572-L582
`AksNodePoolConfig` (where an `OsSku` member would be added):
https://github.com/microsoft/aspire/blob/main/src/Aspire.Hosting.Azure.Kubernetes/AksNodePoolConfig.cs
Notes:
- `ManagedClusterAgentPoolProfile.OSSku` (type `ContainerServiceOSSku`) is available in `Azure.Provisioning.ContainerService` and exposes an `AzureLinux` member, so this is a small, well-supported addition.
- Context: in our environment, the migration tooling (S360) flags node pools not using Azure Linux 3.0. Some of the flagged pools were originally created for testing; if still in use, they should be recreated using the correct templates (Azure Linux 3.0).
- I'm happy to submit a PR implementing the `AksNodePoolConfig.OsSku` property + mapping in `ConfigureAksInfrastructure` once the default-vs-opt-in and API-shape questions are settled.
Contributor guide
Assessment
This issue has not been assessed yet.