-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azurerm_kubernetes_cluster_node_pool
- os_sku
supports update
#26139
Changes from all commits
8a9713a
d51e253
e0a2f95
504d4a7
13e34bf
82a4d8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,18 @@ func resourceKubernetesClusterNodePool() *pluginsdk.Resource { | |
Schema: resourceKubernetesClusterNodePoolSchema(), | ||
|
||
CustomizeDiff: pluginsdk.CustomDiffInSequence( | ||
pluginsdk.ForceNewIfChange("os_sku", func(ctx context.Context, old, new, meta interface{}) bool { | ||
// Ubuntu and AzureLinux are currently the only allowed Linux OSSKU Migration targets. | ||
if old != string(agentpools.OSSKUUbuntu) && old != string(agentpools.OSSKUAzureLinux) { | ||
return true | ||
} | ||
|
||
if new != string(agentpools.OSSKUUbuntu) && new != string(agentpools.OSSKUAzureLinux) { | ||
return true | ||
} | ||
|
||
return false | ||
}), | ||
// The behaviour of the API requires this, but this could be removed when https://github.com/Azure/azure-rest-api-specs/issues/27373 has been addressed | ||
pluginsdk.ForceNewIfChange("upgrade_settings.0.drain_timeout_in_minutes", func(ctx context.Context, old, new, meta interface{}) bool { | ||
return old != 0 && new == 0 | ||
|
@@ -269,7 +281,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema { | |
"os_sku": { | ||
Type: pluginsdk.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I opened a separate PR for |
||
Computed: true, // defaults to Ubuntu if using Linux | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(agentpools.OSSKUAzureLinux), | ||
|
@@ -840,6 +851,10 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int | |
props.Tags = tags.Expand(t) | ||
} | ||
|
||
if d.HasChange("os_sku") { | ||
props.OsSKU = pointer.To(agentpools.OSSKU(d.Get("os_sku").(string))) | ||
} | ||
|
||
if d.HasChange("upgrade_settings") { | ||
upgradeSettingsRaw := d.Get("upgrade_settings").([]interface{}) | ||
props.UpgradeSettings = expandAgentPoolUpgradeSettings(upgradeSettingsRaw) | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -126,7 +126,9 @@ The following arguments are supported: | |||
|
||||
* `pod_subnet_id` - (Optional) The ID of the Subnet where the pods in the Node Pool should exist. Changing this forces a new resource to be created. | ||||
|
||||
* `os_sku` - (Optional) Specifies the OS SKU used by the agent pool. Possible values are `AzureLinux`, `Ubuntu`, `Windows2019` and `Windows2022`. If not specified, the default is `Ubuntu` if OSType=Linux or `Windows2019` if OSType=Windows. And the default Windows OSSKU will be changed to `Windows2022` after Windows2019 is deprecated. Changing this forces a new resource to be created. | ||||
* `os_sku` - (Optional) Specifies the OS SKU used by the agent pool. Possible values are `AzureLinux`, `Ubuntu`, `Windows2019` and `Windows2022`. If not specified, the default is `Ubuntu` if OSType=Linux or `Windows2019` if OSType=Windows. And the default Windows OSSKU will be changed to `Windows2022` after Windows2019 is deprecated. Changing this from `AzureLinux` or `Ubuntu` to `AzureLinux` or `Ubuntu` will not replace the resource, otherwise it forces a new resource to be created. | ||||
|
||||
-> **Note:** This requires that the Preview Feature `Microsoft.ContainerService/OSSKUMigrationPreview` is enabled and the Resource Provider is re-registered, see [the documentation](https://learn.microsoft.com/en-us/azure/azure-linux/tutorial-azure-linux-migration) for more information. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed if it's not really a preview feature anymore
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll remove it when it's GA, currently we still need this feature registered. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it though? That flag isn't registered on our testing subscription
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I'll remove the notice. |
||||
|
||||
* `os_type` - (Optional) The Operating System which should be used for this Node Pool. Changing this forces a new resource to be created. Possible values are `Linux` and `Windows`. Defaults to `Linux`. | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CustomDiff only applies to azurerm_kubernetes_cluster_node_pool resources.
We need a copy of it in kubernetes_cluster_resource.go too so that the logic applies when validating default_node_pool in azurerm_kubernetes_cluster.