Skip to content

Commit

Permalink
Add cycle support for more properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke committed May 28, 2023
1 parent a88ea17 commit 0453b54
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 108 deletions.
14 changes: 0 additions & 14 deletions internal/services/containers/kubernetes_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2060,20 +2060,6 @@ func resourceKubernetesClusterUpdate(d *pluginsdk.ResourceData, meta interface{}
return err
}
}
/*
cycleNodePool := false
cycleNodePoolProperties := []string{"name", "enable_host_encryption", "enable_node_public_ip", "kubelet_config", "linux_os_config", "max_pods",
"node_taints", "only_critical_addons_enabled", "os_disk_size_gb", "os_disk_type", "os_sku", "vm_size", "zones"}
for _, property := range cycleNodePoolProperties {
if d.HasChange("default_node_pool.0." + property) {
cycleNodePool = true
}
}
// if the default node pool name has changed, it means the initial attempt at resizing failed
if cycleNodePool {
*/

if d.HasChange("default_node_pool.0.name") || d.HasChange("default_node_pool.0.enable_host_encryption") || d.HasChange("default_node_pool.0.enable_node_public_ip") || d.HasChange("default_node_pool.0.kubelet_config") || d.HasChange("default_node_pool.0.linux_os_config") || d.HasChange("default_node_pool.0.max_pods") || d.HasChange("default_node_pool.0.node_taints") || d.HasChange("default_node_pool.0.only_critical_addons_enabled") || d.HasChange("default_node_pool.0.os_disk_size_gb") || d.HasChange("default_node_pool.0.os_disk_type") || d.HasChange("default_node_pool.0.os_sku") || d.HasChange("default_node_pool.0.vm_size") || d.HasChange("default_node_pool.0.zones") {
log.Printf("[DEBUG] Cycling Default Node Pool..")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ func TestAccKubernetesCluster_cycleSystemNodePool(t *testing.T) {
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
{
Config: r.updateLinuxKernelSettings(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
})
}

Expand Down Expand Up @@ -512,9 +519,9 @@ resource "azurerm_kubernetes_cluster" "test" {
dns_prefix = "acctestaks%d"
default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2ads_v5"
name = "default"
node_count = 1
vm_size = "Standard_D2ads_v5"
}
identity {
Expand Down Expand Up @@ -624,59 +631,18 @@ resource "azurerm_kubernetes_cluster" "test" {
temporary_name_for_rotation = "temp"
node_count = 1
vm_size = "%s"
zones = %s
zones = %s
enable_node_public_ip = true
max_pods = 60
only_critical_addons_enabled = true
kubelet_config {
cpu_manager_policy = "static"
cpu_cfs_quota_enabled = true
cpu_cfs_quota_period = "10ms"
image_gc_high_threshold = 90
image_gc_low_threshold = 70
topology_manager_policy = "best-effort"
allowed_unsafe_sysctls = ["kernel.msg*", "net.core.somaxconn"]
container_log_max_size_mb = 100
container_log_max_line = 100000
pod_max_pid = 12345
}
kubelet_config {
pod_max_pid = 12346
}
linux_os_config {
transparent_huge_page_enabled = "always"
transparent_huge_page_defrag = "always"
swap_file_size_mb = 300
sysctl_config {
fs_aio_max_nr = 65536
fs_file_max = 100000
fs_inotify_max_user_watches = 1000000
fs_nr_open = 1048576
kernel_threads_max = 200000
net_core_netdev_max_backlog = 1800
net_core_optmem_max = 30000
net_core_rmem_max = 300000
net_core_rmem_default = 300000
net_core_somaxconn = 5000
net_core_wmem_default = 300000
net_core_wmem_max = 300000
net_ipv4_ip_local_port_range_min = 32768
net_ipv4_ip_local_port_range_max = 60000
net_ipv4_neigh_default_gc_thresh1 = 128
net_ipv4_neigh_default_gc_thresh2 = 512
net_ipv4_neigh_default_gc_thresh3 = 1024
net_ipv4_tcp_fin_timeout = 60
net_ipv4_tcp_keepalive_probes = 9
net_ipv4_tcp_keepalive_time = 6000
net_ipv4_tcp_max_syn_backlog = 2048
net_ipv4_tcp_max_tw_buckets = 100000
net_ipv4_tcp_tw_reuse = true
net_ipv4_tcp_keepalive_intvl = 70
net_netfilter_nf_conntrack_buckets = 65536
net_netfilter_nf_conntrack_max = 200000
vm_max_map_count = 65536
vm_swappiness = 45
vm_vfs_cache_pressure = 80
vm_swappiness = 40
}
}
}
Expand All @@ -693,6 +659,55 @@ resource "azurerm_kubernetes_cluster" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, vmSize, zones)
}

func (KubernetesClusterResource) updateLinuxKernelSettings(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"
temporary_name_for_rotation = "temp"
node_count = 1
vm_size = "Standard_D2ads_v5"
enable_node_public_ip = true
max_pods = 60
only_critical_addons_enabled = true
kubelet_config {
pod_max_pid = 12347
}
linux_os_config {
sysctl_config {
vm_swappiness = 45
}
}
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "kubenet"
load_balancer_sku = "standard"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (KubernetesClusterResource) updateOsDisk(data acceptance.TestData, osDiskType string, osDiskSize int) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -755,54 +770,13 @@ resource "azurerm_kubernetes_cluster" "test" {
os_sku = "%s"
vm_size = "Standard_D2ads_v5"
kubelet_config {
cpu_manager_policy = "static"
cpu_cfs_quota_enabled = true
cpu_cfs_quota_period = "10ms"
image_gc_high_threshold = 91
image_gc_low_threshold = 71
topology_manager_policy = "best-effort"
allowed_unsafe_sysctls = ["net.core.somaxconn"]
container_log_max_size_mb = 100
container_log_max_line = 100000
pod_max_pid = 12346
}
kubelet_config {
pod_max_pid = 12346
}
linux_os_config {
transparent_huge_page_enabled = "always"
transparent_huge_page_defrag = "always"
swap_file_size_mb = 301
sysctl_config {
fs_aio_max_nr = 65537
fs_file_max = 100001
fs_inotify_max_user_watches = 1000001
fs_nr_open = 1048575
kernel_threads_max = 200000
net_core_netdev_max_backlog = 1800
net_core_optmem_max = 30000
net_core_rmem_max = 300000
net_core_rmem_default = 300000
net_core_somaxconn = 5000
net_core_wmem_default = 300000
net_core_wmem_max = 300000
net_ipv4_ip_local_port_range_min = 32768
net_ipv4_ip_local_port_range_max = 60000
net_ipv4_neigh_default_gc_thresh1 = 128
net_ipv4_neigh_default_gc_thresh2 = 512
net_ipv4_neigh_default_gc_thresh3 = 1024
net_ipv4_tcp_fin_timeout = 50
net_ipv4_tcp_keepalive_probes = 9
net_ipv4_tcp_keepalive_time = 6000
net_ipv4_tcp_max_syn_backlog = 2048
net_ipv4_tcp_max_tw_buckets = 100000
net_ipv4_tcp_tw_reuse = true
net_ipv4_tcp_keepalive_intvl = 70
net_netfilter_nf_conntrack_buckets = 65536
net_netfilter_nf_conntrack_max = 200000
vm_max_map_count = 65536
vm_swappiness = 40
vm_vfs_cache_pressure = 80
vm_swappiness = 40
}
}
}
Expand Down

0 comments on commit 0453b54

Please sign in to comment.