Skip to content

Commit 911b244

Browse files
saketjajooamukul-25
authored andcommitted
Add support for configuring the Pod Snapshots feature (GoogleCloudPlatform#16096)
1 parent 48211c4 commit 911b244

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ var (
101101
{{- if ne $.TargetVersionName "ga" }}
102102
"addons_config.0.istio_config",
103103
"addons_config.0.kalm_config",
104+
"addons_config.0.pod_snapshot_config",
104105
{{- end }}
105106
}
106107

@@ -557,6 +558,23 @@ func ResourceContainerCluster() *schema.Resource {
557558
},
558559
},
559560
},
561+
"pod_snapshot_config": {
562+
Type: schema.TypeList,
563+
Optional: true,
564+
Computed: true,
565+
AtLeastOneOf: addonsConfigKeys,
566+
MaxItems: 1,
567+
Description: `Configuration for the Pod Snapshot feature.`,
568+
Elem: &schema.Resource{
569+
Schema: map[string]*schema.Schema{
570+
"enabled": {
571+
Type: schema.TypeBool,
572+
Required: true,
573+
Description: `Whether the Pod Snapshot feature is enabled for this cluster.`,
574+
},
575+
},
576+
},
577+
},
560578
{{- end }}
561579
"config_connector_config": {
562580
Type: schema.TypeList,
@@ -5630,6 +5648,14 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
56305648
ForceSendFields: []string{"Enabled"},
56315649
}
56325650
}
5651+
5652+
if v, ok := config["pod_snapshot_config"]; ok && len(v.([]interface{})) > 0 {
5653+
addon := v.([]interface{})[0].(map[string]interface{})
5654+
ac.PodSnapshotConfig = &container.PodSnapshotConfig{
5655+
Enabled: addon["enabled"].(bool),
5656+
ForceSendFields: []string{"Enabled"},
5657+
}
5658+
}
56335659
{{- end }}
56345660

56355661
return ac
@@ -7233,6 +7259,14 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac
72337259
},
72347260
}
72357261
}
7262+
7263+
if c.PodSnapshotConfig != nil {
7264+
result["pod_snapshot_config"] = []map[string]interface{}{
7265+
{
7266+
"enabled": c.PodSnapshotConfig.Enabled,
7267+
},
7268+
}
7269+
}
72367270
{{- end }}
72377271

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

mmv1/third_party/terraform/services/container/resource_container_cluster_meta.yaml.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fields:
3030
{{- end }}
3131
{{- if ne $.TargetVersionName "ga" }}
3232
- api_field: 'addonsConfig.kalmConfig.enabled'
33+
- api_field: 'addonsConfig.podSnapshotConfig.enabled'
3334
{{- end }}
3435
- api_field: 'addonsConfig.lustreCsiDriverConfig.enableLegacyLustrePort'
3536
- api_field: 'addonsConfig.lustreCsiDriverConfig.enabled'

mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7618,6 +7618,9 @@ resource "google_container_cluster" "primary" {
76187618
kalm_config {
76197619
enabled = false
76207620
}
7621+
pod_snapshot_config {
7622+
enabled = false
7623+
}
76217624
{{- end }}
76227625
}
76237626
network = "%s"
@@ -7700,6 +7703,9 @@ resource "google_container_cluster" "primary" {
77007703
kalm_config {
77017704
enabled = true
77027705
}
7706+
pod_snapshot_config {
7707+
enabled = true
7708+
}
77037709
{{- end }}
77047710
}
77057711
network = "%s"

mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,8 @@ Fleet configuration for the cluster. Structure is [documented below](#nested_fle
528528
This flag is required to workaround a port conflict with the gke-metadata-server on GKE nodes.
529529
See [Enable Lustre CSI driver](https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/lustre-csi-driver-new-volume) for more information.
530530

531+
* `pod_snapshot_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) The status of the Pod Snapshot addon. It is disabled by default. Set `enabled = true` to enable.
532+
531533
This example `addons_config` disables two addons:
532534

533535
```hcl

0 commit comments

Comments
 (0)