Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Nov 13, 2023
2 parents 449c024 + a9de2d7 commit fb9e6d4
Show file tree
Hide file tree
Showing 31 changed files with 257 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ Then perform the following commands on the root folder:
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | `list(object({ cidr_block = string, display_name = string }))` | `[]` | no |
| monitoring\_enable\_managed\_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `false` | no |
| monitoring\_enable\_observability\_metrics | Whether or not the advanced datapath metrics are enabled. | `bool` | `false` | no |
| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration. | `list(string)` | `[]` | no |
| monitoring\_observability\_metrics\_relay\_mode | Mode used to make advanced datapath metrics relay available. | `string` | `null` | no |
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | `string` | `"monitoring.googleapis.com/kubernetes"` | no |
| name | The name of the cluster (required) | `string` | n/a | yes |
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |
Expand Down
4 changes: 4 additions & 0 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ resource "google_container_cluster" "primary" {
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
advanced_datapath_observability_config {
enable_metrics = var.monitoring_enable_observability_metrics
relay_mode = var.monitoring_observability_metrics_relay_mode
}
}
}
cluster_autoscaling {
Expand Down
16 changes: 16 additions & 0 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,22 @@ variable "monitoring_enable_managed_prometheus" {
default = false
}

variable "monitoring_enable_observability_metrics" {
type = bool
description = "Whether or not the advanced datapath metrics are enabled."
default = false
}

variable "monitoring_observability_metrics_relay_mode" {
type = string
description = "Mode used to make advanced datapath metrics relay available."
default = null
validation {
condition = var.monitoring_observability_metrics_relay_mode == null ? true : contains(["DISABLED", "INTERNAL_VPC_LB", "EXTERNAL_LB"], var.monitoring_observability_metrics_relay_mode)
error_message = "The advanced datapath metrics relay value must be one of DISABLED, INTERNAL_VPC_LB, EXTERNAL_LB."
}
}

variable "monitoring_enabled_components" {
type = list(string)
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
Expand Down
4 changes: 4 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ resource "google_container_cluster" "primary" {
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
advanced_datapath_observability_config {
enable_metrics = var.monitoring_enable_observability_metrics
relay_mode = var.monitoring_observability_metrics_relay_mode
}
}
}
cluster_autoscaling {
Expand Down
4 changes: 3 additions & 1 deletion modules/asm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module "asm" {
```

Note that the [`mesh_id` label on the cluster](https://cloud.google.com/service-mesh/docs/managed/auto-control-plane-with-fleet#apply_the_mesh_id_label) is required for metrics to get displayed on the Anthos Service Mesh pages in the Cloud console (Topology, etc.). Illustrated with the full example mentioned above, here is an example of what your cluster should have:

```tf
module "gke" {
...
Expand All @@ -58,9 +59,10 @@ To deploy this config:
| enable\_cni | Determines whether to enable CNI for this ASM installation. Required to use Managed Data Plane (MDP). | `bool` | `false` | no |
| enable\_fleet\_registration | Determines whether the module registers the cluster to the fleet. | `bool` | `false` | no |
| enable\_mesh\_feature | Determines whether the module enables the mesh feature on the fleet. | `bool` | `false` | no |
| enable\_vpc\_sc | Determines whether to enable VPC-SC for this ASM installation. For more information read https://cloud.google.com/service-mesh/docs/managed/vpc-sc | `bool` | `false` | no |
| enable\_vpc\_sc | Determines whether to enable VPC-SC for this ASM installation. For more information read [VPC Service Controls for Managed Anthos Service Mesh](https://cloud.google.com/service-mesh/docs/managed/vpc-sc) | `bool` | `false` | no |
| fleet\_id | The fleet to use for this ASM installation. | `string` | `""` | no |
| internal\_ip | Use internal ip for the cluster endpoint when running kubectl commands. | `bool` | `false` | no |
| mesh\_management | ASM Management mode. For more information, see the [gke\_hub\_feature\_membership resource documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature_membership#nested_mesh) | `string` | `""` | no |
| module\_depends\_on | List of modules or resources this module depends on. If multiple, all items must be the same type. | `list(any)` | `[]` | no |
| multicluster\_mode | [Preview] Determines whether remote secrets should be autogenerated across fleet cluster. | `string` | `"manual"` | no |
| project\_id | The project in which the resource belongs. | `string` | n/a | yes |
Expand Down
12 changes: 12 additions & 0 deletions modules/asm/hub.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ resource "google_gke_hub_feature" "mesh" {
location = "global"
provider = google-beta
}

resource "google_gke_hub_feature_membership" "mesh_feature_membership" {
count = var.enable_fleet_registration && var.enable_mesh_feature && var.mesh_management != "" ? 1 : 0

location = "global"
feature = google_gke_hub_feature.mesh[0].name
membership = google_gke_hub_membership.membership[0].membership_id
mesh {
management = var.mesh_management
}
provider = google-beta
}
45 changes: 44 additions & 1 deletion modules/asm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ data "google_container_cluster" "asm" {
}

resource "kubernetes_namespace" "system" {
count = var.create_system_namespace ? 1 : 0
count = var.create_system_namespace && var.mesh_management != "MANAGEMENT_AUTOMATIC" ? 1 : 0

metadata {
name = "istio-system"
}
}

resource "kubernetes_config_map" "asm_options" {
count = var.mesh_management != "MANAGEMENT_AUTOMATIC" ? 1 : 0

metadata {
name = "asm-options"
namespace = try(kubernetes_namespace.system[0].metadata[0].name, "istio-system")
Expand All @@ -56,6 +58,8 @@ resource "kubernetes_config_map" "asm_options" {
}

module "cpr" {
count = var.mesh_management != "MANAGEMENT_AUTOMATIC" ? 1 : 0

source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
version = "~> 3.1"

Expand All @@ -69,3 +73,42 @@ module "cpr" {

module_depends_on = [kubernetes_config_map.asm_options]
}

# Wait for the ControlPlaneRevision custom resource to be ready.
# Add an explicit "retry until the resource is created" until
module "kubectl_asm_wait_for_controlplanerevision_custom_resource_definition" {
count = var.mesh_management == "MANAGEMENT_AUTOMATIC" ? 1 : 0

source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
version = "~> 3.1"

project_id = var.project_id
cluster_name = var.cluster_name
cluster_location = var.cluster_location
kubectl_create_command = "/bin/sh -c 'while ! kubectl wait crd/controlplanerevisions.mesh.cloud.google.com --for condition=established --timeout=60m --all-namespaces; do echo \"crd/controlplanerevisions.mesh.cloud.google.com not yet available, waiting...\"; sleep 5; done'"
kubectl_destroy_command = ""

module_depends_on = [
google_gke_hub_feature_membership.mesh_feature_membership
]
}

# Wait for the ASM control plane revision to be ready so we can safely deploy resources that depend
# on ASM mutating webhooks.
# Add an explicit "retry until the resource is created" until
module "kubectl_asm_wait_for_controlplanerevision" {
count = var.mesh_management == "MANAGEMENT_AUTOMATIC" ? 1 : 0

source = "terraform-google-modules/gcloud/google//modules/kubectl-wrapper"
version = "~> 3.1"

project_id = var.project_id
cluster_name = var.cluster_name
cluster_location = var.cluster_location
kubectl_create_command = "/bin/sh -c 'while ! kubectl -n istio-system wait ControlPlaneRevision --all --timeout=60m --for condition=Reconciled; do echo \"ControlPlaneRevision not yet available, waiting...\"; sleep 5; done'"
kubectl_destroy_command = ""

module_depends_on = [
module.kubectl_asm_wait_for_controlplanerevision_custom_resource_definition[0].wait
]
}
2 changes: 1 addition & 1 deletion modules/asm/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ output "revision_name" {
}

output "wait" {
value = module.cpr.wait
value = var.mesh_management == "MANAGEMENT_AUTOMATIC" ? module.kubectl_asm_wait_for_controlplanerevision[0].wait : module.cpr[0].wait
description = "An output to use when depending on the ASM installation finishing."
}
17 changes: 16 additions & 1 deletion modules/asm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ variable "channel" {
default = ""
}

variable "mesh_management" {
default = ""
description = "ASM Management mode. For more information, see the [gke_hub_feature_membership resource documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/gke_hub_feature_membership#nested_mesh)"
type = string
validation {
condition = anytrue([
var.mesh_management == null,
var.mesh_management == "",
var.mesh_management == "MANAGEMENT_AUTOMATIC",
var.mesh_management == "MANAGEMENT_MANUAL",
])
error_message = "Must be null, empty, or one of MANAGEMENT_AUTOMATIC or MANAGEMENT_MANUAL."
}
}

variable "multicluster_mode" {
description = "[Preview] Determines whether remote secrets should be autogenerated across fleet cluster."
type = string
Expand All @@ -70,7 +85,7 @@ variable "enable_cni" {
}

variable "enable_vpc_sc" {
description = "Determines whether to enable VPC-SC for this ASM installation. For more information read https://cloud.google.com/service-mesh/docs/managed/vpc-sc"
description = "Determines whether to enable VPC-SC for this ASM installation. For more information read [VPC Service Controls for Managed Anthos Service Mesh](https://cloud.google.com/service-mesh/docs/managed/vpc-sc)"
type = bool
default = false
}
Expand Down
2 changes: 1 addition & 1 deletion modules/asm/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

terraform {
required_version = ">= 0.14.0"
required_version = ">= 1.1"

required_providers {
kubernetes = {
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ Then perform the following commands on the root folder:
| master\_global\_access\_enabled | Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint. | `bool` | `true` | no |
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | `string` | `"10.0.0.0/28"` | no |
| monitoring\_enable\_managed\_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `false` | no |
| monitoring\_enable\_observability\_metrics | Whether or not the advanced datapath metrics are enabled. | `bool` | `false` | no |
| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration. | `list(string)` | `[]` | no |
| monitoring\_observability\_metrics\_relay\_mode | Mode used to make advanced datapath metrics relay available. | `string` | `null` | no |
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | `string` | `"monitoring.googleapis.com/kubernetes"` | no |
| name | The name of the cluster (required) | `string` | n/a | yes |
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ resource "google_container_cluster" "primary" {
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
advanced_datapath_observability_config {
enable_metrics = var.monitoring_enable_observability_metrics
relay_mode = var.monitoring_observability_metrics_relay_mode
}
}
}
cluster_autoscaling {
Expand Down
16 changes: 16 additions & 0 deletions modules/beta-private-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,22 @@ variable "monitoring_enable_managed_prometheus" {
default = false
}

variable "monitoring_enable_observability_metrics" {
type = bool
description = "Whether or not the advanced datapath metrics are enabled."
default = false
}

variable "monitoring_observability_metrics_relay_mode" {
type = string
description = "Mode used to make advanced datapath metrics relay available."
default = null
validation {
condition = var.monitoring_observability_metrics_relay_mode == null ? true : contains(["DISABLED", "INTERNAL_VPC_LB", "EXTERNAL_LB"], var.monitoring_observability_metrics_relay_mode)
error_message = "The advanced datapath metrics relay value must be one of DISABLED, INTERNAL_VPC_LB, EXTERNAL_LB."
}
}

variable "monitoring_enabled_components" {
type = list(string)
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ Then perform the following commands on the root folder:
| master\_global\_access\_enabled | Whether the cluster master is accessible globally (from any region) or only within the same region as the private endpoint. | `bool` | `true` | no |
| master\_ipv4\_cidr\_block | (Beta) The IP range in CIDR notation to use for the hosted master network | `string` | `"10.0.0.0/28"` | no |
| monitoring\_enable\_managed\_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `false` | no |
| monitoring\_enable\_observability\_metrics | Whether or not the advanced datapath metrics are enabled. | `bool` | `false` | no |
| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration. | `list(string)` | `[]` | no |
| monitoring\_observability\_metrics\_relay\_mode | Mode used to make advanced datapath metrics relay available. | `string` | `null` | no |
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | `string` | `"monitoring.googleapis.com/kubernetes"` | no |
| name | The name of the cluster (required) | `string` | n/a | yes |
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ resource "google_container_cluster" "primary" {
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
advanced_datapath_observability_config {
enable_metrics = var.monitoring_enable_observability_metrics
relay_mode = var.monitoring_observability_metrics_relay_mode
}
}
}
cluster_autoscaling {
Expand Down
16 changes: 16 additions & 0 deletions modules/beta-private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,22 @@ variable "monitoring_enable_managed_prometheus" {
default = false
}

variable "monitoring_enable_observability_metrics" {
type = bool
description = "Whether or not the advanced datapath metrics are enabled."
default = false
}

variable "monitoring_observability_metrics_relay_mode" {
type = string
description = "Mode used to make advanced datapath metrics relay available."
default = null
validation {
condition = var.monitoring_observability_metrics_relay_mode == null ? true : contains(["DISABLED", "INTERNAL_VPC_LB", "EXTERNAL_LB"], var.monitoring_observability_metrics_relay_mode)
error_message = "The advanced datapath metrics relay value must be one of DISABLED, INTERNAL_VPC_LB, EXTERNAL_LB."
}
}

variable "monitoring_enabled_components" {
type = list(string)
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
Expand Down
2 changes: 2 additions & 0 deletions modules/beta-public-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ Then perform the following commands on the root folder:
| maintenance\_start\_time | Time window specified for daily or recurring maintenance operations in RFC3339 format | `string` | `"05:00"` | no |
| master\_authorized\_networks | List of master authorized networks. If none are provided, disallow external access (except the cluster node IPs, which GKE automatically whitelists). | `list(object({ cidr_block = string, display_name = string }))` | `[]` | no |
| monitoring\_enable\_managed\_prometheus | Configuration for Managed Service for Prometheus. Whether or not the managed collection is enabled. | `bool` | `false` | no |
| monitoring\_enable\_observability\_metrics | Whether or not the advanced datapath metrics are enabled. | `bool` | `false` | no |
| monitoring\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration. | `list(string)` | `[]` | no |
| monitoring\_observability\_metrics\_relay\_mode | Mode used to make advanced datapath metrics relay available. | `string` | `null` | no |
| monitoring\_service | The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none | `string` | `"monitoring.googleapis.com/kubernetes"` | no |
| name | The name of the cluster (required) | `string` | n/a | yes |
| network | The VPC network to host the cluster in (required) | `string` | n/a | yes |
Expand Down
4 changes: 4 additions & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ resource "google_container_cluster" "primary" {
managed_prometheus {
enabled = var.monitoring_enable_managed_prometheus
}
advanced_datapath_observability_config {
enable_metrics = var.monitoring_enable_observability_metrics
relay_mode = var.monitoring_observability_metrics_relay_mode
}
}
}
cluster_autoscaling {
Expand Down
16 changes: 16 additions & 0 deletions modules/beta-public-cluster-update-variant/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,22 @@ variable "monitoring_enable_managed_prometheus" {
default = false
}

variable "monitoring_enable_observability_metrics" {
type = bool
description = "Whether or not the advanced datapath metrics are enabled."
default = false
}

variable "monitoring_observability_metrics_relay_mode" {
type = string
description = "Mode used to make advanced datapath metrics relay available."
default = null
validation {
condition = var.monitoring_observability_metrics_relay_mode == null ? true : contains(["DISABLED", "INTERNAL_VPC_LB", "EXTERNAL_LB"], var.monitoring_observability_metrics_relay_mode)
error_message = "The advanced datapath metrics relay value must be one of DISABLED, INTERNAL_VPC_LB, EXTERNAL_LB."
}
}

variable "monitoring_enabled_components" {
type = list(string)
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS (provider version >= 3.89.0). Empty list is default GKE configuration."
Expand Down
Loading

0 comments on commit fb9e6d4

Please sign in to comment.