Skip to content

Commit

Permalink
Add support for enable_relay field to `advanced_datapath_observabil…
Browse files Browse the repository at this point in the history
…ity_config`

Signed-off-by: Michal Siwinski <[email protected]>
  • Loading branch information
siwiutki committed Jan 15, 2024
1 parent 167cbbe commit 8c5176a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,11 @@ func ResourceContainerCluster() *schema.Resource {
Required: true,
Description: `Whether or not the advanced datapath metrics are enabled.`,
},
"enable_relay": {
Type: schema.TypeBool,
Optional: true,
Description: `Whether or not Relay is enabled.`,
},
"relay_mode": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -5316,6 +5321,7 @@ func expandMonitoringConfig(configured interface{}) *container.MonitoringConfig

mc.AdvancedDatapathObservabilityConfig = &container.AdvancedDatapathObservabilityConfig{
EnableMetrics: advanced_datapath_observability_config["enable_metrics"].(bool),
EnableRelay: advanced_datapath_observability_config["enable_relay"].(bool),
RelayMode: advanced_datapath_observability_config["relay_mode"].(string),
}
}
Expand Down Expand Up @@ -6146,7 +6152,8 @@ func flattenAdvancedDatapathObservabilityConfig(c *container.AdvancedDatapathObs
return []map[string]interface{}{
{
"enable_metrics": c.EnableMetrics,
"relay_mode": c.RelayMode,
"enable_relay": c.EnableRelay,
"relay_mode": c.RelayMode,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,11 @@ func resourceContainerClusterResourceV1() *schema.Resource {
Required: true,
Description: `Whether or not the advanced datapath metrics are enabled.`,
},
"enable_relay": {
Type: schema.TypeBool,
Optional: true,
Description: `Whether or not Relay is enabled.`,
},
"relay_mode": {
Type: schema.TypeString,
Optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3107,6 +3107,15 @@ func TestAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityCo
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckContainerClusterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabledOld(clusterName),
},
{
ResourceName: "google_container_cluster.primary",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"},
},
{
Config: testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabled(clusterName),
},
Expand Down Expand Up @@ -8849,6 +8858,56 @@ resource "google_compute_subnetwork" "container_subnetwork" {
}
}

resource "google_container_cluster" "primary" {
name = "%s"
location = "us-central1-a"
initial_node_count = 1
datapath_provider = "ADVANCED_DATAPATH"

network = google_compute_network.container_network.name
subnetwork = google_compute_subnetwork.container_subnetwork.name
ip_allocation_policy {
cluster_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[0].range_name
services_secondary_range_name = google_compute_subnetwork.container_subnetwork.secondary_ip_range[1].range_name
}

monitoring_config {
enable_components = []
advanced_datapath_observability_config {
enable_metrics = true
enable_relay = true
}
}
deletion_protection = false
}
`, name, name)
}

func testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabledOld(name string) string {
return fmt.Sprintf(`
resource "google_compute_network" "container_network" {
name = "%s-nw"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "container_subnetwork" {
name = google_compute_network.container_network.name
network = google_compute_network.container_network.name
ip_cidr_range = "10.0.36.0/24"
region = "us-central1"
private_ip_google_access = true

secondary_ip_range {
range_name = "services-range"
ip_cidr_range = "192.168.1.0/24"
}

secondary_ip_range {
range_name = "pod-ranges"
ip_cidr_range = "192.168.64.0/22"
}
}

resource "google_container_cluster" "primary" {
name = "%s"
location = "us-central1-a"
Expand Down Expand Up @@ -8916,6 +8975,7 @@ resource "google_container_cluster" "primary" {
enable_components = []
advanced_datapath_observability_config {
enable_metrics = false
enable_relay = false
relay_mode = "DISABLED"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ This block also contains several computed attributes, documented below.
<a name="nested_advanced_datapath_observability_config"></a>The `advanced_datapath_observability_config` block supports:

* `enable_metrics` - (Required) Whether or not to enable advanced datapath metrics.
* `enable_relay` - (Optional) Whether or not Relay is enabled.
* `relay_mode` - (Optional) Mode used to make Relay available.

<a name="nested_maintenance_policy"></a>The `maintenance_policy` block supports:
Expand Down

0 comments on commit 8c5176a

Please sign in to comment.