Skip to content

Commit

Permalink
k8s: Support enabling HA post-create. (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Nov 1, 2023
1 parent 4e52d1b commit 57f343b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions digitalocean/kubernetes/resource_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func ResourceDigitalOceanKubernetesCluster() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
Default: false,
ForceNew: true,
},

"registry_integration": {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions digitalocean/kubernetes/resource_kubernetes_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand All @@ -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"),
),
},
},
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/kubernetes_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 57f343b

Please sign in to comment.