Skip to content

Commit

Permalink
azurerm_kubernetes_cluster - set value of enable_host_encryption
Browse files Browse the repository at this point in the history
…on `default_node_pool` when resizing (#21379)

* set value of host encryption on node pool when resizing

* add preview note for enable_host_encryption
  • Loading branch information
stephybun authored Apr 12, 2023
1 parent 9b7fa06 commit bc7d9f4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestAccKubernetesCluster_updateVmSize(t *testing.T) {

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Config: r.withHostEncryption(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -422,6 +422,42 @@ resource "azurerm_kubernetes_cluster" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (KubernetesClusterResource) withHostEncryption(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-aks-%d"
location = "%s"
}
resource "azurerm_kubernetes_cluster" "test" {
name = "acctestaks%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
dns_prefix = "acctestaks%d"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_DS2_v2"
enable_host_encryption = true
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "kubenet"
load_balancer_sku = "standard"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (KubernetesClusterResource) basicWithTempName(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -480,6 +516,7 @@ resource "azurerm_kubernetes_cluster" "test" {
temporary_name_for_rotation = "temp"
node_count = 1
vm_size = "%s"
enable_host_encryption = true
}
identity {
Expand Down
1 change: 1 addition & 0 deletions internal/services/containers/kubernetes_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ func ConvertDefaultNodePoolToAgentPool(input *[]managedclusters.ManagedClusterAg
MinCount: defaultCluster.MinCount,
EnableAutoScaling: defaultCluster.EnableAutoScaling,
EnableCustomCATrust: defaultCluster.EnableCustomCATrust,
EnableEncryptionAtHost: defaultCluster.EnableEncryptionAtHost,
EnableFIPS: defaultCluster.EnableFIPS,
OrchestratorVersion: defaultCluster.OrchestratorVersion,
ProximityPlacementGroupID: defaultCluster.ProximityPlacementGroupID,
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ A `default_node_pool` block supports the following:

* `enable_host_encryption` - (Optional) Should the nodes in the Default Node Pool have host encryption enabled? Changing this forces a new resource to be created.

-> **Note:** This requires that the Preview Feature `Microsoft.ContainerService/EnableEncryptionAtHostPreview` is enabled and the Resource Provider is re-registered.

* `enable_node_public_ip` - (Optional) Should nodes in this Node Pool have a Public IP Address? Changing this forces a new resource to be created.

* `host_group_id` - (Optional) Specifies the ID of the Host Group within which this AKS Cluster should be created. Changing this forces a new resource to be created.
Expand Down

0 comments on commit bc7d9f4

Please sign in to comment.