From 57f343b03c3550b5af9405da450315f9d46d38d8 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio Date: Wed, 1 Nov 2023 13:34:40 -0400 Subject: [PATCH] k8s: Support enabling HA post-create. (#1058) --- digitalocean/kubernetes/resource_kubernetes_cluster.go | 6 +++--- digitalocean/kubernetes/resource_kubernetes_cluster_test.go | 3 +++ docs/resources/kubernetes_cluster.md | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/digitalocean/kubernetes/resource_kubernetes_cluster.go b/digitalocean/kubernetes/resource_kubernetes_cluster.go index 470301a9a..525980c67 100644 --- a/digitalocean/kubernetes/resource_kubernetes_cluster.go +++ b/digitalocean/kubernetes/resource_kubernetes_cluster.go @@ -62,7 +62,6 @@ func ResourceDigitalOceanKubernetesCluster() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, - ForceNew: true, }, "registry_integration": { @@ -414,13 +413,14 @@ func resourceDigitalOceanKubernetesClusterUpdate(ctx context.Context, d *schema. client := meta.(*config.CombinedConfig).GodoClient() // Figure out the changes and then call the appropriate API methods - if d.HasChanges("name", "tags", "auto_upgrade", "surge_upgrade", "maintenance_policy") { + if d.HasChanges("name", "tags", "auto_upgrade", "surge_upgrade", "maintenance_policy", "ha") { opts := &godo.KubernetesClusterUpdateRequest{ Name: d.Get("name").(string), Tags: tag.ExpandTags(d.Get("tags").(*schema.Set).List()), - AutoUpgrade: godo.Bool(d.Get("auto_upgrade").(bool)), + AutoUpgrade: godo.PtrTo(d.Get("auto_upgrade").(bool)), SurgeUpgrade: d.Get("surge_upgrade").(bool), + HA: godo.PtrTo(d.Get("ha").(bool)), } if maint, ok := d.GetOk("maintenance_policy"); ok { diff --git a/digitalocean/kubernetes/resource_kubernetes_cluster_test.go b/digitalocean/kubernetes/resource_kubernetes_cluster_test.go index 4521c9fd4..269e08bc2 100644 --- a/digitalocean/kubernetes/resource_kubernetes_cluster_test.go +++ b/digitalocean/kubernetes/resource_kubernetes_cluster_test.go @@ -298,6 +298,7 @@ func TestAccDigitalOceanKubernetesCluster_UpdateCluster(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDigitalOceanKubernetesClusterExists("digitalocean_kubernetes_cluster.foobar", &k8s), resource.TestCheckResourceAttr("digitalocean_kubernetes_cluster.foobar", "name", rName), + resource.TestCheckResourceAttr("digitalocean_kubernetes_cluster.foobar", "ha", "false"), ), }, { @@ -310,6 +311,7 @@ func TestAccDigitalOceanKubernetesCluster_UpdateCluster(t *testing.T) { resource.TestCheckTypeSetElemAttr("digitalocean_kubernetes_cluster.foobar", "tags.*", "two"), resource.TestCheckResourceAttr("digitalocean_kubernetes_cluster.foobar", "node_pool.0.labels.%", "0"), resource.TestCheckResourceAttr("digitalocean_kubernetes_cluster.foobar", "surge_upgrade", "true"), + resource.TestCheckResourceAttr("digitalocean_kubernetes_cluster.foobar", "ha", "true"), ), }, }, @@ -865,6 +867,7 @@ resource "digitalocean_kubernetes_cluster" "foobar" { name = "%s" region = "lon1" surge_upgrade = true + ha = true version = data.digitalocean_kubernetes_versions.test.latest_version tags = ["one", "two"] diff --git a/docs/resources/kubernetes_cluster.md b/docs/resources/kubernetes_cluster.md index b1ae6902a..d31f3b9fa 100644 --- a/docs/resources/kubernetes_cluster.md +++ b/docs/resources/kubernetes_cluster.md @@ -148,7 +148,7 @@ The following arguments are supported: * `vpc_uuid` - (Optional) The ID of the VPC where the Kubernetes cluster will be located. * `auto_upgrade` - (Optional) A boolean value indicating whether the cluster will be automatically upgraded to new patch releases during its maintenance window. * `surge_upgrade` - (Optional) Enable/disable surge upgrades for a cluster. Default: false -* `ha` - (Optional) Enable/disable the high availability control plane for a cluster. High availability can only be set when creating a cluster. Any update will create a new cluster. Default: false +* `ha` - (Optional) Enable/disable the high availability control plane for a cluster. Once enabled for a cluster, high availability cannot be disabled. Default: false * `registry_integration` - (optional) Enables or disables the DigitalOcean container registry integration for the cluster. This requires that a container registry has first been created for the account. Default: false * `node_pool` - (Required) A block representing the cluster's default node pool. Additional node pools may be added to the cluster using the `digitalocean_kubernetes_node_pool` resource. The following arguments may be specified: - `name` - (Required) A name for the node pool.