Skip to content

Commit

Permalink
- checks whether the returned upgrade settings block contains any val…
Browse files Browse the repository at this point in the history
…ues, and returns an empty interface if not (#26541)

- reverts a planned 4.0 change where upgrade settings block would become required, this needs to be optional because it cannot be specified for spot node pools
- removes public_network_access_enabled in 4.0 since this property isn't functional
  • Loading branch information
stephybun committed Jul 4, 2024
1 parent 9ba0bc8 commit a7e21ca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1146,33 +1146,9 @@ func resourceKubernetesClusterNodePoolDelete(d *pluginsdk.ResourceData, meta int
}

func upgradeSettingsSchema() *pluginsdk.Schema {
if !features.FourPointOhBeta() {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"max_surge": {
Type: pluginsdk.TypeString,
Required: true,
},
"drain_timeout_in_minutes": {
Type: pluginsdk.TypeInt,
Optional: true,
},
"node_soak_duration_in_minutes": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 30),
},
},
},
}
}
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
Expand Down Expand Up @@ -1278,7 +1254,8 @@ func expandAgentPoolUpgradeSettings(input []interface{}) *agentpools.AgentPoolUp
}

func flattenAgentPoolUpgradeSettings(input *agentpools.AgentPoolUpgradeSettings) []interface{} {
if input == nil {
// The API returns an empty upgrade settings object for spot node pools, so we need to explicitly check whether there's anything in it
if input == nil || (input.MaxSurge == nil && input.DrainTimeoutInMinutes == nil && input.NodeSoakDurationInMinutes == nil) {
return []interface{}{}
}

Expand Down
21 changes: 10 additions & 11 deletions internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
_, err := commonids.ParseKubernetesClusterID(id)
return err
},
// TODO 4.0: we're defaulting this at import time because the property is non-functional.
// In the lead up to 4.0 planning if the feature still isn't functional we should look at
// removing this entirely.

func(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) ([]*pluginsdk.ResourceData, error) {
d.Set("public_network_access_enabled", true)
if !features.FourPointOhBeta() {
d.Set("public_network_access_enabled", true)
}
return []*pluginsdk.ResourceData{d}, nil
},
),
Expand Down Expand Up @@ -1277,13 +1277,6 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
),
},

"public_network_access_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
Deprecated: "`public_network_access_enabled` is currently not functional and is not be passed to the API",
},

"role_based_access_control_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Expand Down Expand Up @@ -1733,6 +1726,12 @@ func resourceKubernetesCluster() *pluginsdk.Resource {
},
ConflictsWith: []string{"web_app_routing.0.dns_zone_id"},
}
resource.Schema["public_network_access_enabled"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
Deprecated: "`public_network_access_enabled` is currently not functional and is not be passed to the API, this property will be removed in v4.0 of the AzureRM provider.",
}
}

if features.FourPointOhBeta() {
Expand Down
3 changes: 2 additions & 1 deletion internal/services/containers/kubernetes_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,8 @@ func FlattenDefaultNodePool(input *[]managedclusters.ManagedClusterAgentPoolProf
}

func flattenClusterNodePoolUpgradeSettings(input *managedclusters.AgentPoolUpgradeSettings) []interface{} {
if input == nil {
// The API returns an empty upgrade settings object for spot node pools, so we need to explicitly check whether there's anything in it
if input == nil || (input.MaxSurge == nil && input.DrainTimeoutInMinutes == nil && input.NodeSoakDurationInMinutes == nil) {
return []interface{}{}
}

Expand Down
4 changes: 0 additions & 4 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,6 @@ resource "azurerm_kubernetes_cluster" "example" {

-> **Note:** Enabling this option will allocate Workload Identity resources to the `kube-system` namespace in Kubernetes. If you wish to customize the deployment of Workload Identity, you can refer to [the documentation on Azure AD Workload Identity.](https://azure.github.io/azure-workload-identity/docs/installation/mutating-admission-webhook.html) The documentation provides guidance on how to install the mutating admission webhook, which allows for the customization of Workload Identity deployment.

* `public_network_access_enabled` - (Optional) Whether public network access is allowed for this Kubernetes Cluster. Defaults to `true`.

!> **Note:** `public_network_access_enabled` is currently not functional and is not passed to the Azure API. For further information please see this [issue](https://github.com/Azure/AKS/issues/3690). For controlling the public and private exposure of a cluster please see the properties `private_cluster_enabled` and `api_server_access_profile`.

* `role_based_access_control_enabled` - (Optional) Whether Role Based Access Control for the Kubernetes Cluster should be enabled. Defaults to `true`. Changing this forces a new resource to be created.

* `run_command_enabled` - (Optional) Whether to enable run command for the cluster or not. Defaults to `true`.
Expand Down

0 comments on commit a7e21ca

Please sign in to comment.