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

Add support for GKE Addon StatefulHA #9481

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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 @@ -4458,6 +4476,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 @@ -5633,6 +5659,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 @@ -5652,6 +5685,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 @@ -4957,6 +4957,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 @@ -5024,6 +5027,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 @@ -448,6 +448,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
Loading