Skip to content

Commit

Permalink
Add support for GKE Addon StatefulHA (#9481)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwschuurman authored Apr 8, 2024
1 parent 5dd1269 commit 0f61d38
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ var (
"addons_config.0.gke_backup_agent_config",
"addons_config.0.config_connector_config",
"addons_config.0.gcs_fuse_csi_driver_config",
"addons_config.0.stateful_ha_config",
<% unless version == 'ga' -%>
"addons_config.0.istio_config",
"addons_config.0.kalm_config",
Expand Down Expand Up @@ -505,6 +506,23 @@ func ResourceContainerCluster() *schema.Resource {
},
},
},
"stateful_ha_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
AtLeastOneOf: addonsConfigKeys,
MaxItems: 1,
Description: `The status of the Stateful HA addon, which provides automatic configurable failover for stateful applications. Defaults to disabled; set enabled = true to enable.`,
ConflictsWith: []string{"enable_autopilot"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
},
},
},
Expand Down Expand Up @@ -4483,6 +4501,14 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
}
}

if v, ok := config["stateful_ha_config"]; ok && len(v.([]interface{})) > 0 {
addon := v.([]interface{})[0].(map[string]interface{})
ac.StatefulHaConfig = &container.StatefulHAConfig{
Enabled: addon["enabled"].(bool),
ForceSendFields: []string{"Enabled"},
}
}

<% unless version == 'ga' -%>
if v, ok := config["istio_config"]; ok && len(v.([]interface{})) > 0 {
addon := v.([]interface{})[0].(map[string]interface{})
Expand Down Expand Up @@ -5658,6 +5684,13 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac
},
}
}
if c.StatefulHaConfig != nil {
result["stateful_ha_config"] = []map[string]interface{}{
{
"enabled": c.StatefulHaConfig.Enabled,
},
}
}

<% unless version == 'ga' -%>
if c.IstioConfig != nil {
Expand All @@ -5677,6 +5710,7 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac
}
}
<% end -%>

return []map[string]interface{}{result}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5038,6 +5038,9 @@ resource "google_container_cluster" "primary" {
gcs_fuse_csi_driver_config {
enabled = false
}
stateful_ha_config {
enabled = false
}
<% unless version == 'ga' -%>
istio_config {
disabled = true
Expand Down Expand Up @@ -5105,6 +5108,9 @@ resource "google_container_cluster" "primary" {
gcs_fuse_csi_driver_config {
enabled = true
}
stateful_ha_config {
enabled = true
}
<% unless version == 'ga' -%>
istio_config {
disabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ Fleet configuration for the cluster. Structure is [documented below](#nested_fle
* `config_connector_config` - (Optional).
The status of the ConfigConnector addon. It is disabled by default; Set `enabled = true` to enable.

* `stateful_ha_config` - (Optional).
The status of the Stateful HA addon, which provides automatic configurable failover for stateful applications.
It is disabled by default for Standard clusters. Set `enabled = true` to enable.

This example `addons_config` disables two addons:

Expand Down

0 comments on commit 0f61d38

Please sign in to comment.