Skip to content

Commit aa7fa8d

Browse files
Add support for advanced_datapath_observability_config to google_container_cluster (#8516) (#6027)
Signed-off-by: Aditya Sharma <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 2ea532e commit aa7fa8d

File tree

5 files changed

+186
-11
lines changed

5 files changed

+186
-11
lines changed

.changelog/8516.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
container: added support for `advanced_datapath_observability_config` to `google_container_cluster`
3+
```

go.sum

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ bitbucket.org/creachadair/stringset v0.0.8 h1:gQqe4vs8XWgMyijfyKE6K8o4TcyGGrRXe0
22
bitbucket.org/creachadair/stringset v0.0.8/go.mod h1:AgthVMyMxC/6FK1KBJ2ALdqkZObGN8hOetgpwXyMn34=
33
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
44
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
5-
cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys=
6-
cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY=
75
cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA=
86
cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw=
97
cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk=
@@ -16,12 +14,8 @@ cloud.google.com/go/compute v1.20.1 h1:6aKEtlUiwEpJzM001l0yFkpXmUVXaN8W+fbkb2AZN
1614
cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
1715
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
1816
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
19-
cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k=
20-
cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0=
2117
cloud.google.com/go/iam v1.1.0 h1:67gSqaPukx7O8WLLHMa0PNs3EBGd2eE4d+psbO/CO94=
2218
cloud.google.com/go/iam v1.1.0/go.mod h1:nxdHjaKfCr7fNYx/HJMM8LgiMugmveWlkatear5gVyk=
23-
cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM=
24-
cloud.google.com/go/longrunning v0.4.1/go.mod h1:4iWDqhBZ70CvZ6BfETbvam3T8FMvLK+eFj0E6AaRQTo=
2519
cloud.google.com/go/longrunning v0.5.0 h1:DK8BH0+hS+DIvc9a2TPnteUievsTCH4ORMAASSb7JcQ=
2620
cloud.google.com/go/longrunning v0.5.0/go.mod h1:0JNuqRShmscVAhIACGtskSAWtqtOoPkwP0YF1oVEchc=
2721
cloud.google.com/go/longrunning v0.5.1 h1:Fr7TXftcqTudoyRJa113hyaqlGdiBQkp0Gq7tErFDWI=
@@ -212,7 +206,6 @@ github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKL
212206
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
213207
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
214208
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
215-
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
216209
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
217210
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
218211
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
@@ -273,7 +266,6 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
273266
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
274267
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
275268
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
276-
github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
277269
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
278270
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
279271
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
@@ -328,7 +320,6 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL
328320
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
329321
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
330322
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
331-
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
332323
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
333324
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
334325
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -494,4 +485,3 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
494485
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
495486
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
496487
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
497-
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=

google-beta/resource_container_cluster_test.go

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,37 @@ func TestAccContainerCluster_withLoggingConfig(t *testing.T) {
27142714
})
27152715
}
27162716

2717+
func TestAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfig(t *testing.T) {
2718+
t.Parallel()
2719+
2720+
clusterName := fmt.Sprintf("tf-test-cluster-%s", acctest.RandString(t, 10))
2721+
acctest.VcrTest(t, resource.TestCase{
2722+
PreCheck: func() { acctest.AccTestPreCheck(t) },
2723+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
2724+
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
2725+
Steps: []resource.TestStep{
2726+
{
2727+
Config: testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabled(clusterName),
2728+
},
2729+
{
2730+
ResourceName: "google_container_cluster.primary",
2731+
ImportState: true,
2732+
ImportStateVerify: true,
2733+
ImportStateVerifyIgnore: []string{"min_master_version"},
2734+
},
2735+
{
2736+
Config: testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigDisabled(clusterName),
2737+
},
2738+
{
2739+
ResourceName: "google_container_cluster.primary",
2740+
ImportState: true,
2741+
ImportStateVerify: true,
2742+
ImportStateVerifyIgnore: []string{"min_master_version"},
2743+
},
2744+
},
2745+
})
2746+
}
2747+
27172748
func TestAccContainerCluster_withMonitoringConfig(t *testing.T) {
27182749
t.Parallel()
27192750

@@ -7752,6 +7783,104 @@ resource "google_container_cluster" "primary" {
77527783
`, name)
77537784
}
77547785

7786+
func testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabled(name string) string {
7787+
return fmt.Sprintf(`
7788+
resource "google_compute_network" "container_network" {
7789+
name = "%s-nw"
7790+
auto_create_subnetworks = false
7791+
}
7792+
7793+
resource "google_compute_subnetwork" "container_subnetwork" {
7794+
name = google_compute_network.container_network.name
7795+
network = google_compute_network.container_network.name
7796+
ip_cidr_range = "10.0.36.0/24"
7797+
region = "us-central1"
7798+
private_ip_google_access = true
7799+
7800+
secondary_ip_range {
7801+
range_name = "services-range"
7802+
ip_cidr_range = "192.168.1.0/24"
7803+
}
7804+
7805+
secondary_ip_range {
7806+
range_name = "pod-ranges"
7807+
ip_cidr_range = "192.168.64.0/22"
7808+
}
7809+
}
7810+
7811+
resource "google_container_cluster" "primary" {
7812+
name = "%s"
7813+
location = "us-central1-a"
7814+
initial_node_count = 1
7815+
datapath_provider = "ADVANCED_DATAPATH"
7816+
7817+
network = google_compute_network.container_network.name
7818+
subnetwork = google_compute_subnetwork.container_subnetwork.name
7819+
ip_allocation_policy {
7820+
cluster_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[0].range_name
7821+
services_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[1].range_name
7822+
}
7823+
7824+
monitoring_config {
7825+
enable_components = []
7826+
advanced_datapath_observability_config {
7827+
enable_metrics = true
7828+
relay_mode = "INTERNAL_VPC_LB"
7829+
}
7830+
}
7831+
}
7832+
`, name, name)
7833+
}
7834+
7835+
func testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigDisabled(name string) string {
7836+
return fmt.Sprintf(`
7837+
resource "google_compute_network" "container_network" {
7838+
name = "%s-nw"
7839+
auto_create_subnetworks = false
7840+
}
7841+
7842+
resource "google_compute_subnetwork" "container_subnetwork" {
7843+
name = google_compute_network.container_network.name
7844+
network = google_compute_network.container_network.name
7845+
ip_cidr_range = "10.0.36.0/24"
7846+
region = "us-central1"
7847+
private_ip_google_access = true
7848+
7849+
secondary_ip_range {
7850+
range_name = "services-range"
7851+
ip_cidr_range = "192.168.1.0/24"
7852+
}
7853+
7854+
secondary_ip_range {
7855+
range_name = "pod-ranges"
7856+
ip_cidr_range = "192.168.64.0/22"
7857+
}
7858+
}
7859+
7860+
resource "google_container_cluster" "primary" {
7861+
name = "%s"
7862+
location = "us-central1-a"
7863+
initial_node_count = 1
7864+
datapath_provider = "ADVANCED_DATAPATH"
7865+
7866+
network = google_compute_network.container_network.name
7867+
subnetwork = google_compute_subnetwork.container_subnetwork.name
7868+
ip_allocation_policy {
7869+
cluster_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[0].range_name
7870+
services_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[1].range_name
7871+
}
7872+
7873+
monitoring_config {
7874+
enable_components = []
7875+
advanced_datapath_observability_config {
7876+
enable_metrics = false
7877+
relay_mode = "DISABLED"
7878+
}
7879+
}
7880+
}
7881+
`, name, name)
7882+
}
7883+
77557884
func testAccContainerCluster_withSoleTenantGroup(name string) string {
77567885
return fmt.Sprintf(`
77577886
resource "google_compute_node_template" "soletenant-tmpl" {

google-beta/services/container/resource_container_cluster.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,29 @@ func ResourceContainerCluster() *schema.Resource {
11561156
},
11571157
},
11581158
},
1159+
"advanced_datapath_observability_config": {
1160+
Type: schema.TypeList,
1161+
Optional: true,
1162+
Computed: true,
1163+
MaxItems: 2,
1164+
Description: `Configuration of Advanced Datapath Observability features.`,
1165+
Elem: &schema.Resource{
1166+
Schema: map[string]*schema.Schema{
1167+
"enable_metrics": {
1168+
Type: schema.TypeBool,
1169+
Required: true,
1170+
Description: `Whether or not the advanced datapath metrics are enabled.`,
1171+
},
1172+
"relay_mode": {
1173+
Type: schema.TypeString,
1174+
Optional: true,
1175+
Computed: true,
1176+
Description: `Mode used to make Relay available.`,
1177+
ValidateFunc: validation.StringInSlice([]string{"DISABLED", "INTERNAL_VPC_LB", "EXTERNAL_LB"}, false),
1178+
},
1179+
},
1180+
},
1181+
},
11591182
},
11601183
},
11611184
},
@@ -4987,6 +5010,16 @@ func expandMonitoringConfig(configured interface{}) *container.MonitoringConfig
49875010
Enabled: managed_prometheus["enabled"].(bool),
49885011
}
49895012
}
5013+
5014+
if v, ok := config["advanced_datapath_observability_config"]; ok && len(v.([]interface{})) > 0 {
5015+
advanced_datapath_observability_config := v.([]interface{})[0].(map[string]interface{})
5016+
5017+
mc.AdvancedDatapathObservabilityConfig = &container.AdvancedDatapathObservabilityConfig{
5018+
EnableMetrics: advanced_datapath_observability_config["enable_metrics"].(bool),
5019+
RelayMode: advanced_datapath_observability_config["relay_mode"].(string),
5020+
}
5021+
}
5022+
49905023
return mc
49915024
}
49925025

@@ -5772,9 +5805,22 @@ func flattenMonitoringConfig(c *container.MonitoringConfig) []map[string]interfa
57725805
if c.ManagedPrometheusConfig != nil {
57735806
result["managed_prometheus"] = flattenManagedPrometheusConfig(c.ManagedPrometheusConfig)
57745807
}
5808+
if c.AdvancedDatapathObservabilityConfig != nil {
5809+
result["advanced_datapath_observability_config"] = flattenAdvancedDatapathObservabilityConfig(c.AdvancedDatapathObservabilityConfig)
5810+
}
5811+
57755812
return []map[string]interface{}{result}
57765813
}
57775814

5815+
func flattenAdvancedDatapathObservabilityConfig(c *container.AdvancedDatapathObservabilityConfig) []map[string]interface{} {
5816+
return []map[string]interface{}{
5817+
{
5818+
"enable_metrics": c.EnableMetrics,
5819+
"relay_mode": c.RelayMode,
5820+
},
5821+
}
5822+
}
5823+
57785824
func flattenManagedPrometheusConfig(c *container.ManagedPrometheusConfig) []map[string]interface{} {
57795825
return []map[string]interface{}{
57805826
{

website/docs/r/container_cluster.html.markdown

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,17 @@ This block also contains several computed attributes, documented below.
595595

596596
* `managed_prometheus` - (Optional) Configuration for Managed Service for Prometheus. Structure is [documented below](#nested_managed_prometheus).
597597

598+
* `advanced_datapath_observability_config` - (Optional) Configuration for Advanced Datapath Monitoring. Structure is [documented below](#nested_advanced_datapath_observability_config).
599+
598600
<a name="nested_managed_prometheus"></a>The `managed_prometheus` block supports:
599601

600602
* `enabled` - (Required) Whether or not the managed collection is enabled.
601603

604+
<a name="nested_advanced_datapath_observability_config"></a>The `advanced_datapath_observability_config` block supports:
605+
606+
* `enabled_metrics` - (Required) Whether or not the advanced datapath metrics are enabled.
607+
* `relay_mode` - (Optional) Mode used to make Relay available.
608+
602609
<a name="nested_maintenance_policy"></a>The `maintenance_policy` block supports:
603610
* `daily_maintenance_window` - (Optional) structure documented below.
604611
* `recurring_window` - (Optional) structure documented below
@@ -712,7 +719,7 @@ to have a range chosen with a specific netmask. Set to a CIDR notation (e.g. 10.
712719
from the RFC-1918 private networks (e.g. 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) to
713720
pick a specific range to use.
714721

715-
* `stack_type` - (Optional) The IP Stack Type of the cluster.
722+
* `stack_type` - (Optional) The IP Stack Type of the cluster.
716723
Default value is `IPV4`.
717724
Possible values are `IPV4` and `IPV4_IPV6`.
718725

0 commit comments

Comments
 (0)