Skip to content

Commit

Permalink
kalm (K8s Application lifecycle manager) addon config added (#3459) (#…
Browse files Browse the repository at this point in the history
…2027)

* kalm addon config added

* kalm addon tests added

* Update resource_container_cluster_test.go.erb

* PR comments fixed

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored May 2, 2020
1 parent c47b906 commit 22ec205
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/3459.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
* container: added `kalm_config` addon to `google_container_cluster` (beta-only)
```
32 changes: 32 additions & 0 deletions google-beta/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var (
"addons_config.0.cloudrun_config",
"addons_config.0.dns_cache_config",
"addons_config.0.gce_persistent_disk_csi_driver_config",
"addons_config.0.kalm_config",
}
)

Expand Down Expand Up @@ -302,6 +303,21 @@ func resourceContainerCluster() *schema.Resource {
},
},
},
"kalm_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
AtLeastOneOf: addonsConfigKeys,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
},
},
},
Expand Down Expand Up @@ -2212,6 +2228,14 @@ func expandClusterAddonsConfig(configured interface{}) *containerBeta.AddonsConf
}
}

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

return ac
}

Expand Down Expand Up @@ -2624,6 +2648,14 @@ func flattenClusterAddonsConfig(c *containerBeta.AddonsConfig) []map[string]inte
},
}
}

if c.KalmConfig != nil {
result["kalm_config"] = []map[string]interface{}{
{
"enabled": c.KalmConfig.Enabled,
},
}
}
return []map[string]interface{}{result}
}

Expand Down
8 changes: 7 additions & 1 deletion google-beta/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,9 @@ resource "google_container_cluster" "primary" {
gce_persistent_disk_csi_driver_config {
enabled = false
}
kalm_config {
enabled = false
}
}
}
`, clusterName)
Expand Down Expand Up @@ -2011,7 +2014,10 @@ resource "google_container_cluster" "primary" {
}
gce_persistent_disk_csi_driver_config {
enabled = true
}
}
kalm_config {
enabled = true
}
}
}
`, clusterName)
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ The `addons_config` block supports:
* `gce_persistent_disk_csi_driver_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to disabled; set `enabled = true` to enable.

* `kalm_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).
Configuration for the KALM addon, which manages the lifecycle of k8s. It is disabled by default; Set `enabled = true` to enable.

This example `addons_config` disables two addons:

```hcl
Expand Down

0 comments on commit 22ec205

Please sign in to comment.