Skip to content

Commit

Permalink
Containerservices agentpoolprofile maxpods (#1753)
Browse files Browse the repository at this point in the history
* Added max_pods to agent_pool_profiles in azurerm_kubernetes_cluster

* Added ForceNew and Default to max_pods

* Added max_pods to data_source_kubernetes_cluster agent_profile

* Updated the docs to include max_pods

* Fixed my terrible English. (I'm a flawed person)

* Changed max_pods to computed field

* Fixed max_pods field (added optional flag back in)

* Conditionally passing max_pods to SDK

* Removed default pod count from documentation

* Added test coverage for max_pods

* Fixed intentation

* Trying to fix indentations
  • Loading branch information
lfshr authored and tombuildsstuff committed Aug 14, 2018
1 parent 59c6609 commit d2bcb26
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions azurerm/data_source_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"max_pods": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -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)
}

Expand Down
15 changes: 15 additions & 0 deletions azurerm/resource_arm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ func resourceArmKubernetesCluster() *schema.Resource {
}, true),
DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},

"max_pods": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
},
},
},
},
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions azurerm/resource_arm_kubernetes_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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"),
),
},
},
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit d2bcb26

Please sign in to comment.