Skip to content
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 - support updating default_node_pool.linux_os_config.sysctl_config #24397

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,36 @@ func TestAccKubernetesCluster_kubeletAndLinuxOSConfig(t *testing.T) {
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
})
}

func TestAccKubernetesCluster_kubeletAndLinuxOSConfigUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.kubeletAndLinuxOSConfigPartial(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
{
Config: r.kubeletAndLinuxOSConfig(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
{
Config: r.kubeletAndLinuxOSConfigPartial(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
})
}

Expand All @@ -125,7 +154,7 @@ func TestAccKubernetesCluster_kubeletAndLinuxOSConfigPartial(t *testing.T) {
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
data.ImportStep("default_node_pool.0.temporary_name_for_rotation"),
})
}

Expand Down Expand Up @@ -1421,9 +1450,10 @@ resource "azurerm_kubernetes_cluster" "test" {
dns_prefix = "acctestaks%d"

default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_DS2_v2"
name = "default"
node_count = 1
vm_size = "Standard_DS2_v2"
temporary_name_for_rotation = "temp"
kubelet_config {
cpu_manager_policy = "static"
cpu_cfs_quota_enabled = true
Expand Down Expand Up @@ -1501,9 +1531,10 @@ resource "azurerm_kubernetes_cluster" "test" {
dns_prefix = "acctestaks%d"

default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_DS2_v2"
name = "default"
node_count = 1
vm_size = "Standard_DS2_v2"
temporary_name_for_rotation = "temp"
kubelet_config {
cpu_manager_policy = "static"
cpu_cfs_quota_enabled = true
Expand Down
186 changes: 185 additions & 1 deletion internal/services/containers/kubernetes_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ func schemaNodePoolLinuxOSConfigForceNew() *pluginsdk.Schema {
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"sysctl_config": schemaNodePoolSysctlConfig(),
"sysctl_config": schemaNodePoolSysctlConfigForceNew(),

"transparent_huge_page_enabled": {
Type: pluginsdk.TypeString,
Expand Down Expand Up @@ -605,6 +605,190 @@ func schemaNodePoolLinuxOSConfigForceNew() *pluginsdk.Schema {
}

func schemaNodePoolSysctlConfig() *pluginsdk.Schema {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"fs_aio_max_nr": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(65536, 6553500),
},

"fs_file_max": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(8192, 12000500),
},

"fs_inotify_max_user_watches": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(781250, 2097152),
},

"fs_nr_open": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(8192, 20000500),
},

"kernel_threads_max": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(20, 513785),
},

"net_core_netdev_max_backlog": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(1000, 3240000),
},

"net_core_optmem_max": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(20480, 4194304),
},

"net_core_rmem_default": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(212992, 134217728),
},

"net_core_rmem_max": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(212992, 134217728),
},

"net_core_somaxconn": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(4096, 3240000),
},

"net_core_wmem_default": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(212992, 134217728),
},

"net_core_wmem_max": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(212992, 134217728),
},

"net_ipv4_ip_local_port_range_min": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(1024, 60999),
},

"net_ipv4_ip_local_port_range_max": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(32768, 65535),
},

"net_ipv4_neigh_default_gc_thresh1": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(128, 80000),
},

"net_ipv4_neigh_default_gc_thresh2": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(512, 90000),
},

"net_ipv4_neigh_default_gc_thresh3": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(1024, 100000),
},

"net_ipv4_tcp_fin_timeout": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(5, 120),
},

"net_ipv4_tcp_keepalive_intvl": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(10, 90),
},

"net_ipv4_tcp_keepalive_probes": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(1, 15),
},

"net_ipv4_tcp_keepalive_time": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(30, 432000),
},

"net_ipv4_tcp_max_syn_backlog": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(128, 3240000),
},

"net_ipv4_tcp_max_tw_buckets": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(8000, 1440000),
},

"net_ipv4_tcp_tw_reuse": {
Type: pluginsdk.TypeBool,
Optional: true,
},

"net_netfilter_nf_conntrack_buckets": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(65536, 524288),
},

"net_netfilter_nf_conntrack_max": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(131072, 2097152),
},

"vm_max_map_count": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(65530, 262144),
},

"vm_swappiness": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 100),
},

"vm_vfs_cache_pressure": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 100),
},
},
},
}
}

func schemaNodePoolSysctlConfigForceNew() *pluginsdk.Schema {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
Expand Down
60 changes: 30 additions & 30 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ A `linux_os_config` block supports the following:

* `swap_file_size_mb` - (Optional) Specifies the size of the swap file on each node in MB.

* `sysctl_config` - (Optional) A `sysctl_config` block as defined below. Changing this forces a new resource to be created.
* `sysctl_config` - (Optional) A `sysctl_config` block as defined below.

* `transparent_huge_page_defrag` - (Optional) specifies the defrag configuration for Transparent Huge Page. Possible values are `always`, `defer`, `defer+madvise`, `madvise` and `never`.

Expand Down Expand Up @@ -821,63 +821,63 @@ A `sysctl_config` block supports the following:

~> For more information, please refer to [Linux Kernel Doc](https://www.kernel.org/doc/html/latest/admin-guide/sysctl/index.html).

* `fs_aio_max_nr` - (Optional) The sysctl setting fs.aio-max-nr. Must be between `65536` and `6553500`. Changing this forces a new resource to be created.
* `fs_aio_max_nr` - (Optional) The sysctl setting fs.aio-max-nr. Must be between `65536` and `6553500`.

* `fs_file_max` - (Optional) The sysctl setting fs.file-max. Must be between `8192` and `12000500`. Changing this forces a new resource to be created.
* `fs_file_max` - (Optional) The sysctl setting fs.file-max. Must be between `8192` and `12000500`.

* `fs_inotify_max_user_watches` - (Optional) The sysctl setting fs.inotify.max_user_watches. Must be between `781250` and `2097152`. Changing this forces a new resource to be created.
* `fs_inotify_max_user_watches` - (Optional) The sysctl setting fs.inotify.max_user_watches. Must be between `781250` and `2097152`.

* `fs_nr_open` - (Optional) The sysctl setting fs.nr_open. Must be between `8192` and `20000500`. Changing this forces a new resource to be created.
* `fs_nr_open` - (Optional) The sysctl setting fs.nr_open. Must be between `8192` and `20000500`.

* `kernel_threads_max` - (Optional) The sysctl setting kernel.threads-max. Must be between `20` and `513785`. Changing this forces a new resource to be created.
* `kernel_threads_max` - (Optional) The sysctl setting kernel.threads-max. Must be between `20` and `513785`.

* `net_core_netdev_max_backlog` - (Optional) The sysctl setting net.core.netdev_max_backlog. Must be between `1000` and `3240000`. Changing this forces a new resource to be created.
* `net_core_netdev_max_backlog` - (Optional) The sysctl setting net.core.netdev_max_backlog. Must be between `1000` and `3240000`.

* `net_core_optmem_max` - (Optional) The sysctl setting net.core.optmem_max. Must be between `20480` and `4194304`. Changing this forces a new resource to be created.
* `net_core_optmem_max` - (Optional) The sysctl setting net.core.optmem_max. Must be between `20480` and `4194304`.

* `net_core_rmem_default` - (Optional) The sysctl setting net.core.rmem_default. Must be between `212992` and `134217728`. Changing this forces a new resource to be created.
* `net_core_rmem_default` - (Optional) The sysctl setting net.core.rmem_default. Must be between `212992` and `134217728`.

* `net_core_rmem_max` - (Optional) The sysctl setting net.core.rmem_max. Must be between `212992` and `134217728`. Changing this forces a new resource to be created.
* `net_core_rmem_max` - (Optional) The sysctl setting net.core.rmem_max. Must be between `212992` and `134217728`.

* `net_core_somaxconn` - (Optional) The sysctl setting net.core.somaxconn. Must be between `4096` and `3240000`. Changing this forces a new resource to be created.
* `net_core_somaxconn` - (Optional) The sysctl setting net.core.somaxconn. Must be between `4096` and `3240000`.

* `net_core_wmem_default` - (Optional) The sysctl setting net.core.wmem_default. Must be between `212992` and `134217728`. Changing this forces a new resource to be created.
* `net_core_wmem_default` - (Optional) The sysctl setting net.core.wmem_default. Must be between `212992` and `134217728`.

* `net_core_wmem_max` - (Optional) The sysctl setting net.core.wmem_max. Must be between `212992` and `134217728`. Changing this forces a new resource to be created.
* `net_core_wmem_max` - (Optional) The sysctl setting net.core.wmem_max. Must be between `212992` and `134217728`.

* `net_ipv4_ip_local_port_range_max` - (Optional) The sysctl setting net.ipv4.ip_local_port_range max value. Must be between `32768` and `65535`. Changing this forces a new resource to be created.
* `net_ipv4_ip_local_port_range_max` - (Optional) The sysctl setting net.ipv4.ip_local_port_range max value. Must be between `32768` and `65535`.

* `net_ipv4_ip_local_port_range_min` - (Optional) The sysctl setting net.ipv4.ip_local_port_range min value. Must be between `1024` and `60999`. Changing this forces a new resource to be created.
* `net_ipv4_ip_local_port_range_min` - (Optional) The sysctl setting net.ipv4.ip_local_port_range min value. Must be between `1024` and `60999`.

* `net_ipv4_neigh_default_gc_thresh1` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh1. Must be between `128` and `80000`. Changing this forces a new resource to be created.
* `net_ipv4_neigh_default_gc_thresh1` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh1. Must be between `128` and `80000`.

* `net_ipv4_neigh_default_gc_thresh2` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh2. Must be between `512` and `90000`. Changing this forces a new resource to be created.
* `net_ipv4_neigh_default_gc_thresh2` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh2. Must be between `512` and `90000`.

* `net_ipv4_neigh_default_gc_thresh3` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh3. Must be between `1024` and `100000`. Changing this forces a new resource to be created.
* `net_ipv4_neigh_default_gc_thresh3` - (Optional) The sysctl setting net.ipv4.neigh.default.gc_thresh3. Must be between `1024` and `100000`.

* `net_ipv4_tcp_fin_timeout` - (Optional) The sysctl setting net.ipv4.tcp_fin_timeout. Must be between `5` and `120`. Changing this forces a new resource to be created.
* `net_ipv4_tcp_fin_timeout` - (Optional) The sysctl setting net.ipv4.tcp_fin_timeout. Must be between `5` and `120`.

* `net_ipv4_tcp_keepalive_intvl` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_intvl. Must be between `10` and `90`. Changing this forces a new resource to be created.
* `net_ipv4_tcp_keepalive_intvl` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_intvl. Must be between `10` and `90`.

* `net_ipv4_tcp_keepalive_probes` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_probes. Must be between `1` and `15`. Changing this forces a new resource to be created.
* `net_ipv4_tcp_keepalive_probes` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_probes. Must be between `1` and `15`.

* `net_ipv4_tcp_keepalive_time` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_time. Must be between `30` and `432000`. Changing this forces a new resource to be created.
* `net_ipv4_tcp_keepalive_time` - (Optional) The sysctl setting net.ipv4.tcp_keepalive_time. Must be between `30` and `432000`.

* `net_ipv4_tcp_max_syn_backlog` - (Optional) The sysctl setting net.ipv4.tcp_max_syn_backlog. Must be between `128` and `3240000`. Changing this forces a new resource to be created.
* `net_ipv4_tcp_max_syn_backlog` - (Optional) The sysctl setting net.ipv4.tcp_max_syn_backlog. Must be between `128` and `3240000`.

* `net_ipv4_tcp_max_tw_buckets` - (Optional) The sysctl setting net.ipv4.tcp_max_tw_buckets. Must be between `8000` and `1440000`. Changing this forces a new resource to be created.
* `net_ipv4_tcp_max_tw_buckets` - (Optional) The sysctl setting net.ipv4.tcp_max_tw_buckets. Must be between `8000` and `1440000`.

* `net_ipv4_tcp_tw_reuse` - (Optional) The sysctl setting net.ipv4.tcp_tw_reuse. Changing this forces a new resource to be created.
* `net_ipv4_tcp_tw_reuse` - (Optional) The sysctl setting net.ipv4.tcp_tw_reuse.

* `net_netfilter_nf_conntrack_buckets` - (Optional) The sysctl setting net.netfilter.nf_conntrack_buckets. Must be between `65536` and `524288`. Changing this forces a new resource to be created.
* `net_netfilter_nf_conntrack_buckets` - (Optional) The sysctl setting net.netfilter.nf_conntrack_buckets. Must be between `65536` and `524288`.

* `net_netfilter_nf_conntrack_max` - (Optional) The sysctl setting net.netfilter.nf_conntrack_max. Must be between `131072` and `2097152`. Changing this forces a new resource to be created.
* `net_netfilter_nf_conntrack_max` - (Optional) The sysctl setting net.netfilter.nf_conntrack_max. Must be between `131072` and `2097152`.

* `vm_max_map_count` - (Optional) The sysctl setting vm.max_map_count. Must be between `65530` and `262144`. Changing this forces a new resource to be created.
* `vm_max_map_count` - (Optional) The sysctl setting vm.max_map_count. Must be between `65530` and `262144`.

* `vm_swappiness` - (Optional) The sysctl setting vm.swappiness. Must be between `0` and `100`. Changing this forces a new resource to be created.
* `vm_swappiness` - (Optional) The sysctl setting vm.swappiness. Must be between `0` and `100`.

* `vm_vfs_cache_pressure` - (Optional) The sysctl setting vm.vfs_cache_pressure. Must be between `0` and `100`. Changing this forces a new resource to be created.
* `vm_vfs_cache_pressure` - (Optional) The sysctl setting vm.vfs_cache_pressure. Must be between `0` and `100`.

---

Expand Down
Loading