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 for auto scaling #3361

Merged
merged 3 commits into from
Jul 3, 2019
Merged

azurerm_kubernetes_cluster - support for auto scaling #3361

merged 3 commits into from
Jul 3, 2019

Conversation

jlpedrosa
Copy link
Contributor

@jlpedrosa jlpedrosa commented May 2, 2019

Hi

This PR adds auto scale and availability zones capabilities to AKS resource and data providers.

It bumps the API version for AKS, there are other PR pending regarding that matter so I expect a conflict depends on what gets merged first.
https://github.com/terraform-providers/terraform-provider-azurerm/pull/3262

This depends on the following features:
az feature register --namespace Microsoft.ContainerService -n AvailabilityZonePreview
az feature register --namespace Microsoft.ContainerService --name VMSSPreview
az provider register -n Microsoft.ContainerService

@katbyte
Copy link
Collaborator

katbyte commented May 7, 2019

Duplicate of #3174

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @jlpedrosa,

As the other AKS PR was closed i am going to review and proceed with this one. OVerall it looks good, and thanks for the good property combination validation! Whats left is:

  • merge/rebase off master
  • test that updates the properties
  • updating the docs

azurerm/resource_arm_kubernetes_cluster.go Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster_test.go Outdated Show resolved Hide resolved
@jlpedrosa
Copy link
Contributor Author

Hi @katbyte

Your guess was correct regarding the limits, in the docs the thershold is 100 [https://docs.microsoft.com/en-us/azure/aks/quotas-skus-regions](aks limits)

I've rebased the PR (there were some conflicts).
Added the validations
Added the documentation
terraform fmt the test code (taking it to a file outside .go code and fmt then copying it back).

regarding: "test that updates the properties", as I mentioned in #317 the moment we change the type of agent pool to VMScaleSets (which is required for autoscaling, but it can be enabled withoutautoscaling). Then any put request to the api will fail (which means no updates will work with that type of agent pool).

@ghost ghost removed the waiting-response label May 22, 2019
@katbyte
Copy link
Collaborator

katbyte commented May 22, 2019

FYI, for future reference i have a tool that will run terraform fmt on blocks of tf code in the tests files: https://github.com/katbyte/terrafmt

@ghost ghost added size/L and removed size/XL labels May 24, 2019
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates @jlpedrosa, i've left some comments inline

azurerm/data_source_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster_test.go Outdated Show resolved Hide resolved
website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/r/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
Copy link

@funnybirdman funnybirdman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor typo

website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
@jlpedrosa
Copy link
Contributor Author

jlpedrosa commented Jun 13, 2019

@tombuildsstuff @katbyte

I ran the tests against my subscription, everything seemed fine. Do you know when it could me merged?

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @jlpedrosa

Thanks for pushing those changes - apologies for the delayed re-review here!

Taking a look through this is looking good, if we can fix up the remaining minor comments this otherwise LGTM 👍

Thanks!

azurerm/data_source_kubernetes_cluster.go Outdated Show resolved Hide resolved
website/docs/r/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved

if profile.AvailabilityZones != nil && len(*profile.AvailabilityZones) > 0 {
agentPoolProfile["availability_zones"] = utils.FlattenStringSlice(profile.AvailabilityZones)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove this if statement around this flatten? the utils.FlattenStringSlice should handle this being nil (and we should always set this complex type if there's no elements, since that'll then show a diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tombuildsstuff:
In this case, I am protecting us against some behaviours of the API where an empty array is not the same as not sending an array.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here we are setting the terraform side. Any protection on the API side should be where we set that property on the SDK (only set it if tf data is !nil and len > 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it here and just left it on the expand. Is that OK?

azurerm/data_source_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@jlpedrosa
Copy link
Contributor Author

Hi @tombuildsstuff

I've rebased it, but your comments were addressed few days ago, I don't know if you could have a look.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jlpedrosa,

Thank you for the updates, i've left some comments inline and replied to yours so that once addressed this should be good to merge

website/docs/r/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved

* `enable_auto_scaling` - (Optional) Whether to enable auto-scaler [Autoscaling details](https://docs.microsoft.com/en-us/azure/aks/cluster-autoscaler)

~> **Note:** Support for the `type` of `VirtualMachineScaleSets` is currently in Public Preview on an opt-in basis. You can enable this feature using the Azure CLI by running `az feature register --name VMSSPreview --namespace Microsoft.ContainerService`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is spurious as its duplicated below?

Copy link
Contributor Author

@jlpedrosa jlpedrosa Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi
if you mean

~>  **Note:** Support for the `type` of `VirtualMachineScaleSets` is currently in Public Preview on an opt-in basis. You can enable this feature using the Azure CLI by running `az feature register --name VMSSPreview --namespace Microsoft.ContainerService`

No, it's not duplicated, it is a requirement for autoscale sets, it only works with VirtualMachineScaleSets. I've added more comments in the doc and remove the line. Let me know if now is clear or how would you prefer it.


if profile.AvailabilityZones != nil && len(*profile.AvailabilityZones) > 0 {
agentPoolProfile["availability_zones"] = utils.FlattenStringSlice(profile.AvailabilityZones)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here we are setting the terraform side. Any protection on the API side should be where we set that property on the SDK (only set it if tf data is !nil and len > 0)

azurerm/data_source_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/data_source_kubernetes_cluster.go Outdated Show resolved Hide resolved
azurerm/resource_arm_kubernetes_cluster.go Outdated Show resolved Hide resolved
website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/d/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/r/kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
@katbyte katbyte modified the milestones: v1.31.0, v1.32.0 Jun 28, 2019
@jlpedrosa
Copy link
Contributor Author

Hi @katbyte

I've fixed most of the comments, and final questions to few. Please your feedback, I've rebased and squashed it as it was giving merge errors. Sorry for the delay.

@ghost ghost removed the waiting-response label Jul 1, 2019
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates @jlpedrosa, aside from one minor comment this LGTM now 👍

Hope you don't mind but i am going to push a fix for that last comment to get this merged 🙂

@@ -1481,6 +1546,8 @@ resource "azurerm_kubernetes_cluster" "test" {
name = "default"
count = "1"
vm_size = "Standard_DS2_v2"
name = "default"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property has been duplicated

Suggested change
name = "default"

@katbyte katbyte merged commit 6f8adc9 into hashicorp:master Jul 3, 2019
@katbyte katbyte changed the title Aks autoscale azurerm_kubernetes_cluster - support for auto scaling Jul 3, 2019
katbyte added a commit that referenced this pull request Jul 3, 2019
@TVH7
Copy link

TVH7 commented Jul 18, 2019

When will the new release be pushed? Waiting for this..

@TVH7
Copy link

TVH7 commented Jul 19, 2019

@katbyte I've seen that the milestone deadline was yesterday however no new release has been made. Any updates?

@PatricioDanos
Copy link

I'm also waiting for this release. Is there any news when it's going to be GA?

@TVH7
Copy link

TVH7 commented Jul 24, 2019

I'm also waiting for this release. Is there any news when it's going to be GA?

So according to my latest info they have a milestone open for the next release. This is already a week overdue (although it says 2 days overdue, but that is because they keep moving the due date.)

However, we are now at 97% complete so I'm expecting @katbyte to release today or tomorrow (24th/25th of July)

A confirmation by @katbyte would be appreciated though.

Link to the milestone: https://github.com/terraform-providers/terraform-provider-azurerm/milestone/48

@PatricioDanos
Copy link

I'm also waiting for this release. Is there any news when it's going to be GA?

So according to my latest info they have a milestone open for the next release. This is already a week overdue (although it says 2 days overdue, but that is because they keep moving the due date.)

However, we are now at 97% complete so I'm expecting @katbyte to release today or tomorrow (24th/25th of July)

A confirmation by @katbyte would be appreciated though.

Link to the milestone: https://github.com/terraform-providers/terraform-provider-azurerm/milestone/48

We're now at 100% so it should be released asap.

@ghost
Copy link

ghost commented Jul 30, 2019

This has been released in version 1.32.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 1.32.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Aug 3, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants