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

Azure Kubernetes Service: 2020-06 updates #7233

Merged
merged 55 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f25d744
r/kubernetes_cluster: support for load balancer settings
tombuildsstuff May 27, 2020
5c0da25
d/kubernetes_cluster: making all read-only properties read-only
tombuildsstuff May 27, 2020
5f01359
Add Orchestrator version for Kubernetes Cluster and Node Pool
titilambert Mar 9, 2020
2c7d831
tests: splitting the test dictionaries amongst the files to reduce co…
tombuildsstuff May 27, 2020
a5299f3
r/kubernetes_cluster: comments from PR review
tombuildsstuff May 27, 2020
c86ac06
r/kubernetes_cluster_(node_pool): validating the orchestrator version…
tombuildsstuff May 28, 2020
3ef2bdc
r/kubernetes_cluster: mapping `spot_max_price` for the default node pool
tombuildsstuff May 28, 2020
84cd429
r/kubernetes_cluster_(node_pool): adding a note covering the version …
tombuildsstuff May 28, 2020
fb3ec28
r/kubernetes_cluster: Azure Policy is not supported in US Government.…
tombuildsstuff May 28, 2020
6d2256c
init kubernetes_cluster auto_scale_profile
Apr 24, 2020
0188f09
r/kubernetes_cluster: fixing pr comments
tombuildsstuff May 29, 2020
e222692
r/kubernetes_cluster: grouping optional fields
tombuildsstuff May 29, 2020
0af18ac
dependencies: updating to use 2020-03 of the containerservice api
tombuildsstuff May 29, 2020
5348f2a
r/kubernetes_cluster: support for the Paid SKU (a.k.a. Uptime SLA)
tombuildsstuff May 29, 2020
7b59502
fixing broken tests from merge conflicts
tombuildsstuff May 29, 2020
2101cdf
r/kubernetes_cluster: exposing the `balance_similar_node_groups` fiel…
tombuildsstuff May 29, 2020
ccd95cd
r/kubernetes_cluster_node_pool: support for configuring `mode`
tombuildsstuff May 29, 2020
8a217b8
Add support for encrypted disks in aks
jlpedrosa May 27, 2020
9b433d8
d|r/kubernetes_cluster: comments from the pr
tombuildsstuff May 29, 2020
4117153
Enable AKS AAD integration v2 + SDK version bump
jlpedrosa May 18, 2020
94c85d2
r/kubernetes_cluster_node_pool: allowing updating of the `mode` field
tombuildsstuff Jun 2, 2020
d0a603f
r/kubernetes_cluster: support for v2 of the azure policy addon
tombuildsstuff Jun 2, 2020
3151a8f
r/kubernetes_cluster: `kubernetes_dashboard` is not supported in US G…
tombuildsstuff Jun 2, 2020
77a6311
r/kubernetes_cluster: azure policy is not supported in China
tombuildsstuff Jun 2, 2020
c73f55d
r/kubernetes_cluster: raising an error when trying to upgrade the kub…
tombuildsstuff Jun 3, 2020
b652136
r/kubernetes_cluster: support for spot node pools
tombuildsstuff Jun 3, 2020
ed061ef
validating the `spot_max_price` and `max_bid_price` fields
tombuildsstuff Jun 3, 2020
e71e9ae
r/kubernetes_cluster_node_pool: fixing the test
tombuildsstuff Jun 3, 2020
1e18641
r/kubernetes_cluster_node_pool: changing node_labels/node_taints forc…
tombuildsstuff Jun 3, 2020
8fded1e
r/kubernetes_cluster: node_labels and node_taints within the default_…
tombuildsstuff Jun 3, 2020
086f9cc
r/kubernetes_cluster: test for azure policy v1 to v2 is combined
tombuildsstuff Jun 3, 2020
a214236
r/kubernetes_cluster: updating the field name to match the schema
tombuildsstuff Jun 3, 2020
b7d9f14
r/kubernetes_cluster: fixing the test TestAccAzureRMKubernetesCluster…
tombuildsstuff Jun 4, 2020
5877109
r/kubernetes_cluster: updating the versions being used for testing
tombuildsstuff Jun 4, 2020
4955cf5
r/kubernetes_cluster: fixing the test TestAccAzureRMKubernetesCluster…
tombuildsstuff Jun 4, 2020
d00392d
r/kubernetes_cluster: always setting the `idle_timeout_in_minutes` field
tombuildsstuff Jun 4, 2020
82dedbb
d/kubernetes_cluster: fixing a test compilation issue
tombuildsstuff Jun 4, 2020
56824c4
r/kubernetes_cluster: only searching for system node pools
tombuildsstuff Jun 4, 2020
bc6226f
r/kubernetes_cluster: fixing a test assertion
tombuildsstuff Jun 4, 2020
cd1282f
r/kubernetes_cluster: fixing the broken assertion
tombuildsstuff Jun 5, 2020
3eabe45
New Data Source: `azurerm_kubernetes_cluster_node_pool`
tombuildsstuff Jun 5, 2020
1dadbca
cleanup
tombuildsstuff Jun 5, 2020
6dee2b2
terrafmt
tombuildsstuff Jun 5, 2020
53bbabd
r/kubewrnetes_cluster: keeping the linter happy
tombuildsstuff Jun 5, 2020
b9e698f
r/kubernetes_cluster: fixing pr comments
tombuildsstuff Jun 5, 2020
2d5198b
r/kubernetes_cluster: fixing the key vault test
tombuildsstuff Jun 5, 2020
8c22d58
r/kubernetes_cluster: supporting delta-updates for the `load_balancer…
tombuildsstuff Jun 8, 2020
fe08fce
linting
tombuildsstuff Jun 8, 2020
ed3c9ce
r/kubernetes_cluster: conditionally setting the `managed_outbound_ip_…
tombuildsstuff Jun 8, 2020
e3b88ce
r/kubernetes_cluster_node_pool: fixing the test `TestAccAzureRMKubern…
tombuildsstuff Jun 8, 2020
6cd6681
(d|r)/kubernetes_cluster: `version` is no longer applicable for `azur…
tombuildsstuff Jun 8, 2020
d4e1e0a
r/kubernetes_cluster: conditionally nil-ing the load balancer profile
tombuildsstuff Jun 9, 2020
05378e6
gosimple
tombuildsstuff Jun 9, 2020
c4cee44
d/kubernetes-cluster: removing the `version` field from the `azure_po…
tombuildsstuff Jun 10, 2020
87d0519
r/kubernetes_cluster_node_pool: making the CheckDestroy test support …
tombuildsstuff Jun 10, 2020
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 @@ -147,9 +147,10 @@ func resourceArmLinuxVirtualMachineScaleSet() *schema.Resource {
"identity": VirtualMachineScaleSetIdentitySchema(),

"max_bid_price": {
Type: schema.TypeFloat,
Optional: true,
Default: -1,
Type: schema.TypeFloat,
Optional: true,
Default: -1,
ValidateFunc: validate.SpotMaxPrice,
},

"overprovision": {
Expand Down
28 changes: 28 additions & 0 deletions azurerm/internal/services/compute/validate/spot_max_price.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package validate

import (
"fmt"
)

// SpotMaxPrice validates the price provided is a valid Spot Price for the Compute
// API (and downstream API's which use this like AKS)
func SpotMaxPrice(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(float64)
if !ok {
errors = append(errors, fmt.Errorf("expected type of %q to be float", k))
return
}

// either -1 (the current VM price)
if v == -1.0 {
return
}

// at least 0.00001
if v < 0.00001 {
errors = append(errors, fmt.Errorf("expected %q to be > 0.00001 but got %.5f", k, v))
return
}

return
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/compute/parse"
computeValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/compute/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/base64"
azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema"
Expand Down Expand Up @@ -159,9 +160,10 @@ func resourceArmWindowsVirtualMachineScaleSet() *schema.Resource {
},

"max_bid_price": {
Type: schema.TypeFloat,
Optional: true,
Default: -1,
Type: schema.TypeFloat,
Optional: true,
Default: -1,
ValidateFunc: computeValidate.SpotMaxPrice,
},

"overprovision": {
Expand Down
2 changes: 1 addition & 1 deletion azurerm/internal/services/containers/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
"github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2018-09-01/containerregistry"
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-02-01/containerservice"
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-03-01/containerservice"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common"
)
Expand Down
29 changes: 27 additions & 2 deletions azurerm/internal/services/containers/kubernetes_addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-02-01/containerservice"
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-03-01/containerservice"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
Expand All @@ -29,10 +29,13 @@ const (
var unsupportedAddonsForEnvironment = map[string][]string{
azure.ChinaCloud.Name: {
aciConnectorKey, // https://github.com/terraform-providers/terraform-provider-azurerm/issues/5510
azurePolicyKey, // https://github.com/terraform-providers/terraform-provider-azurerm/issues/6462
httpApplicationRoutingKey, // https://github.com/terraform-providers/terraform-provider-azurerm/issues/5960
},
azure.USGovernmentCloud.Name: {
azurePolicyKey, // https://github.com/terraform-providers/terraform-provider-azurerm/issues/6702
httpApplicationRoutingKey, // https://github.com/terraform-providers/terraform-provider-azurerm/issues/5960
kubernetesDashboardKey, // https://github.com/terraform-providers/terraform-provider-azurerm/issues/7136
},
}

Expand Down Expand Up @@ -74,6 +77,18 @@ func schemaKubernetesAddOnProfiles() *schema.Schema {
Type: schema.TypeBool,
Required: true,
},

"version": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
// NOTE: v1 will be removed "after Spring 2020" - https://github.com/terraform-providers/terraform-provider-azurerm/issues/6994
// The current cluster uses policy add-on V1. Please migrate to V2 by disabling the add-on, and re-enabling it.
// Azure Policy will not support V1 after spring 2020. V2 is a breaking change, so please read carefully on the instruction and impact at: https://aka.ms/akspolicydoc
"v1",
"v2",
}, false),
},
},
},
},
Expand Down Expand Up @@ -231,10 +246,13 @@ func expandKubernetesAddOnProfiles(input []interface{}, env azure.Environment) (
if len(azurePolicy) > 0 && azurePolicy[0] != nil {
value := azurePolicy[0].(map[string]interface{})
enabled := value["enabled"].(bool)
version := value["version"].(string)

addonProfiles[azurePolicyKey] = &containerservice.ManagedClusterAddonProfile{
Enabled: utils.Bool(enabled),
Config: nil,
Config: map[string]*string{
"version": utils.String(version),
},
}
}

Expand Down Expand Up @@ -308,8 +326,15 @@ func flattenKubernetesAddOnProfiles(profile map[string]*containerservice.Managed
enabled = *enabledVal
}

// not returned for v1
version := "v1"
if versionVal, ok := azurePolicy.Config["version"]; ok && *versionVal != "" {
version = *versionVal
}

azurePolicies = append(azurePolicies, map[string]interface{}{
"enabled": enabled,
"version": version,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-02-01/containerservice"
"github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2020-03-01/containerservice"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/kubernetes"
Expand Down Expand Up @@ -114,6 +114,10 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"version": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
Expand Down Expand Up @@ -186,6 +190,11 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
Computed: true,
},

"orchestrator_version": {
Type: schema.TypeString,
Computed: true,
},

"max_pods": {
Type: schema.TypeInt,
Computed: true,
Expand All @@ -201,13 +210,13 @@ func dataSourceArmKubernetesCluster() *schema.Resource {

"node_taints": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},

"enable_node_public_ip": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
},
},
Expand All @@ -231,17 +240,20 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
},
},

"disk_encryption_set_id": {
Type: schema.TypeString,
Computed: true,
},

"private_link_enabled": {
Type: schema.TypeBool,
Computed: true,
Optional: true,
ConflictsWith: []string{"private_cluster_enabled"},
Deprecated: "Deprecated in favor of `private_cluster_enabled`", // TODO -- remove this in next major version
},

"private_cluster_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true, // TODO -- remove this when deprecation resolves
ConflictsWith: []string{"private_link_enabled"},
},
Expand Down Expand Up @@ -481,11 +493,24 @@ func dataSourceArmKubernetesCluster() *schema.Resource {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"admin_group_object_ids": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},

"client_app_id": {
Type: schema.TypeString,
Computed: true,
},

"managed": {
Type: schema.TypeBool,
Computed: true,
},

"server_app_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -553,6 +578,7 @@ func dataSourceArmKubernetesClusterRead(d *schema.ResourceData, meta interface{}
if props := resp.ManagedClusterProperties; props != nil {
d.Set("dns_prefix", props.DNSPrefix)
d.Set("fqdn", props.Fqdn)
d.Set("disk_encryption_set_id", props.DiskEncryptionSetID)
d.Set("private_fqdn", props.PrivateFQDN)
d.Set("kubernetes_version", props.KubernetesVersion)
d.Set("node_resource_group", props.NodeResourceGroup)
Expand Down Expand Up @@ -647,21 +673,35 @@ func flattenKubernetesClusterDataSourceRoleBasedAccessControl(input *containerse

results := make([]interface{}, 0)
if profile := input.AadProfile; profile != nil {
output := make(map[string]interface{})
adminGroupObjectIds := utils.FlattenStringSlice(profile.AdminGroupObjectIDs)

clientAppId := ""
if profile.ClientAppID != nil {
output["client_app_id"] = *profile.ClientAppID
clientAppId = *profile.ClientAppID
}

managed := false
if profile.Managed != nil {
managed = *profile.Managed
}

serverAppId := ""
if profile.ServerAppID != nil {
output["server_app_id"] = *profile.ServerAppID
serverAppId = *profile.ServerAppID
}

tenantId := ""
if profile.TenantID != nil {
output["tenant_id"] = *profile.TenantID
tenantId = *profile.TenantID
}

results = append(results, output)
results = append(results, map[string]interface{}{
"admin_group_object_ids": adminGroupObjectIds,
"client_app_id": clientAppId,
"managed": managed,
"server_app_id": serverAppId,
"tenant_id": tenantId,
})
}

return []interface{}{
Expand Down Expand Up @@ -772,8 +812,14 @@ func flattenKubernetesClusterDataSourceAddonProfiles(profile map[string]*contain
enabled = *enabledVal
}

version := "v1"
if versionVal, ok := azurePolicy.Config["version"]; ok && *versionVal != "" {
version = *versionVal
}

output := map[string]interface{}{
"enabled": enabled,
"version": version,
}
azurePolicies = append(azurePolicies, output)
}
Expand Down Expand Up @@ -864,6 +910,10 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi
agentPoolProfile["os_type"] = string(profile.OsType)
}

if profile.OrchestratorVersion != nil && *profile.OrchestratorVersion != "" {
agentPoolProfile["orchestrator_version"] = *profile.OrchestratorVersion
}

if profile.MaxPods != nil {
agentPoolProfile["max_pods"] = int(*profile.MaxPods)
}
Expand Down
Loading