diff --git a/azurerm/data_source_kubernetes_cluster.go b/azurerm/data_source_kubernetes_cluster.go index ae3255e6c1bd..e4d96f1b57c7 100644 --- a/azurerm/data_source_kubernetes_cluster.go +++ b/azurerm/data_source_kubernetes_cluster.go @@ -149,6 +149,11 @@ func dataSourceArmKubernetesCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "max_pods": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, @@ -339,6 +344,10 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi agentPoolProfile["os_type"] = string(profile.OsType) } + if profile.MaxPods != nil { + agentPoolProfile["max_pods"] = int(*profile.MaxPods) + } + agentPoolProfiles = append(agentPoolProfiles, agentPoolProfile) } diff --git a/azurerm/resource_arm_kubernetes_cluster.go b/azurerm/resource_arm_kubernetes_cluster.go index 329e1aa85878..987d1dca19db 100644 --- a/azurerm/resource_arm_kubernetes_cluster.go +++ b/azurerm/resource_arm_kubernetes_cluster.go @@ -224,6 +224,13 @@ func resourceArmKubernetesCluster() *schema.Resource { }, true), DiffSuppressFunc: ignoreCaseDiffSuppressFunc, }, + + "max_pods": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ForceNew: true, + }, }, }, }, @@ -532,6 +539,10 @@ func flattenAzureRmKubernetesClusterAgentPoolProfiles(profiles *[]containerservi agentPoolProfile["os_type"] = string(profile.OsType) } + if profile.MaxPods != nil { + agentPoolProfile["max_pods"] = int(*profile.MaxPods) + } + agentPoolProfiles = append(agentPoolProfiles, agentPoolProfile) } @@ -691,6 +702,10 @@ func expandAzureRmKubernetesClusterAgentProfiles(d *schema.ResourceData) []conta OsType: containerservice.OSType(osType), } + if maxPods := int32(config["max_pods"].(int)); maxPods > 0 { + profile.MaxPods = utils.Int32(maxPods) + } + vnetSubnetID := config["vnet_subnet_id"].(string) if vnetSubnetID != "" { profile.VnetSubnetID = utils.String(vnetSubnetID) diff --git a/azurerm/resource_arm_kubernetes_cluster_test.go b/azurerm/resource_arm_kubernetes_cluster_test.go index 762ffabf2b78..bc4c6f6eefda 100644 --- a/azurerm/resource_arm_kubernetes_cluster_test.go +++ b/azurerm/resource_arm_kubernetes_cluster_test.go @@ -91,6 +91,7 @@ func TestAccAzureRMKubernetesCluster_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "kube_config.0.host"), resource.TestCheckResourceAttrSet(resourceName, "kube_config.0.username"), resource.TestCheckResourceAttrSet(resourceName, "kube_config.0.password"), + resource.TestCheckResourceAttrSet(resourceName, "agent_pool_profile.0.max_pods"), ), }, }, @@ -172,6 +173,7 @@ func TestAccAzureRMKubernetesCluster_internalNetwork(t *testing.T) { Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMKubernetesClusterExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "agent_pool_profile.0.max_pods", "60"), ), }, }, @@ -387,6 +389,7 @@ resource "azurerm_kubernetes_cluster" "test" { count = "2" vm_size = "Standard_DS2_v2" vnet_subnet_id = "${azurerm_subnet.test.id}" + max_pods = 60 } service_principal { diff --git a/website/docs/d/kubernetes_cluster.html.markdown b/website/docs/d/kubernetes_cluster.html.markdown index fe538fe2846c..19f2abdf97bc 100644 --- a/website/docs/d/kubernetes_cluster.html.markdown +++ b/website/docs/d/kubernetes_cluster.html.markdown @@ -107,6 +107,7 @@ provider "kubernetes" { * `os_disk_size_gb` - The size of the Agent VM's Operating System Disk in GB. * `os_type` - The Operating System used for the Agents. * `vnet_subnet_id` - The ID of the Subnet where the Agents in the Pool are provisioned. +* `max_pods` - The maximum number of pods that can run on each agent. `service_principal` supports the following: diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index 43b2f6ec5c33..454990981a4b 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -209,6 +209,7 @@ The following arguments are supported: * `os_disk_size_gb` - (Optional) The Agent Operating System disk size in GB. Changing this forces a new resource to be created. * `os_type` - (Optional) The Operating System used for the Agents. Possible values are `Linux` and `Windows`. Changing this forces a new resource to be created. Defaults to `Linux`. * `vnet_subnet_id` - (Optional) The ID of the Subnet where the Agents in the Pool should be provisioned. Changing this forces a new resource to be created. +* `max_pods` - (Optional) The maximum number of pods that can run on each agent. `service_principal` supports the following: