Skip to content

Commit

Permalink
Merge branch 'master' into nap-image-type
Browse files Browse the repository at this point in the history
  • Loading branch information
endrec committed Apr 22, 2024
2 parents 98126ae + f7c2ed9 commit 2ae62a3
Show file tree
Hide file tree
Showing 48 changed files with 819 additions and 74 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ Then perform the following commands on the root folder:
| enable\_confidential\_nodes | An optional flag to enable confidential node config. | `bool` | `false` | no |
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
| enable\_kubernetes\_alpha | Whether to enable Kubernetes Alpha features for this cluster. Note that when this option is enabled, the cluster cannot be upgraded and will be automatically deleted after 30 days. | `bool` | `false` | no |
| enable\_l4\_ilb\_subsetting | Enable L4 ILB Subsetting on the cluster | `bool` | `false` | no |
| enable\_mesh\_certificates | Controls the issuance of workload mTLS certificates. When enabled the GKE Workload Identity Certificates controller and node agent will be deployed in the cluster. Requires Workload Identity. | `bool` | `false` | no |
| enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | `bool` | `false` | no |
| enable\_resource\_consumption\_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | `bool` | `true` | no |
Expand Down Expand Up @@ -192,14 +193,15 @@ Then perform the following commands on the root folder:
| 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\_enabled\_components | List of services to monitor: SYSTEM\_COMPONENTS, WORKLOADS. 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 |
| network\_policy | Enable network policy addon | `bool` | `false` | no |
| network\_policy\_provider | The network policy provider. | `string` | `"CALICO"` | no |
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | `string` | `""` | no |
| network\_tags | (Optional) - List of network tags applied to auto-provisioned node pools. | `list(string)` | `[]` | no |
| node\_metadata | Specifies how node metadata is exposed to the workload running on the node | `string` | `"GKE_METADATA"` | no |
| node\_pools | List of maps containing node pools | `list(map(any))` | <pre>[<br> {<br> "name": "default-node-pool"<br> }<br>]</pre> | no |
| node\_pools\_labels | Map of maps containing node labels by node-pool name | `map(map(string))` | <pre>{<br> "all": {},<br> "default-node-pool": {}<br>}</pre> | no |
Expand Down Expand Up @@ -294,6 +296,8 @@ The node_pools variable takes the following parameters:
| key | The key required for the taint | | Required |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
Expand Down
3 changes: 1 addition & 2 deletions autogen/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ The node_pools variable takes the following parameters:
| key | The key required for the taint | | Required |
| logging_variant | The type of logging agent that is deployed by default for newly created node pools in the cluster. Valid values include DEFAULT and MAX_THROUGHPUT. | DEFAULT | Optional |
| local_ssd_count | The amount of local SSD disks that will be attached to each cluster node and may be used as a `hostpath` volume or a `local` PersistentVolume. | 0 | Optional |
{% if beta_cluster %}
| local_ssd_ephemeral_count | The amount of local SSD disks that will be attached to each cluster node and assigned as scratch space as an `emptyDir` volume. If unspecified, ephemeral storage is backed by the cluster node boot disk. | 0 | Optional |
{% endif %}
| local_nvme_ssd_count | Number of raw-block local NVMe SSD disks to be attached to the node.Each local SSD is 375 GB in size. If zero, it means no raw-block local NVMe SSD disks to be attached to the node. | 0 | Optional |
| machine_type | The name of a Google Compute Engine machine type | e2-medium | Optional |
| min_cpu_platform | Minimum CPU platform to be used by the nodes in the pool. The nodes may be scheduled on the specified or newer CPU platform. | " " | Optional |
| max_count | Maximum number of nodes in the NodePool. Must be >= min_count. Cannot be used with total limits. | 100 | Optional |
Expand Down
20 changes: 19 additions & 1 deletion autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ resource "google_container_cluster" "primary" {
enabled = identity_service_config.value
}
}
{% endif %}

enable_l4_ilb_subsetting = var.enable_l4_ilb_subsetting
{% endif %}
{% endif %}
{% if beta_cluster %}
enable_fqdn_network_policy = var.enable_fqdn_network_policy
{% endif %}
Expand Down Expand Up @@ -241,6 +241,17 @@ resource "google_container_cluster" "primary" {
}
{% endif %}

{% if autopilot_cluster != true %}
dynamic "node_pool_auto_config" {
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
content {
network_tags {
tags = var.network_tags
}
}
}
{% endif %}

master_auth {
client_certificate_config {
issue_client_certificate = var.issue_client_certificate
Expand Down Expand Up @@ -840,6 +851,13 @@ resource "google_container_node_pool" "windows_pools" {
}
{% endif %}

dynamic "local_nvme_ssd_block_config" {
for_each = lookup(each.value, "local_nvme_ssd_count", 0) > 0 ? [1] : []
content {
local_ssd_count = local_nvme_ssd_block_config.value
}
}

service_account = lookup(
each.value,
"service_account",
Expand Down
19 changes: 9 additions & 10 deletions autogen/main/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,12 @@ variable "node_pools_oauth_scopes" {
}
{% endif %}

{% if autopilot_cluster %}
variable "network_tags" {
description = "(Optional, Beta) - List of network tags applied to auto-provisioned node pools."
description = "(Optional) - List of network tags applied to auto-provisioned node pools."
type = list(string)
default = []
}
{% endif %}

variable "stub_domains" {
type = map(list(string))
description = "Map of stub domains and their resolvers to forward DNS queries for a certain domain to an external DNS server"
Expand Down Expand Up @@ -762,7 +761,7 @@ variable "monitoring_observability_metrics_relay_mode" {

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."
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS. Empty list is default GKE configuration."
default = []
}

Expand All @@ -783,6 +782,12 @@ variable "config_connector" {
description = "Whether ConfigConnector is enabled for this cluster."
default = false
}

variable "enable_l4_ilb_subsetting" {
type = bool
description = "Enable L4 ILB Subsetting on the cluster"
default = false
}
{% endif %}
{% if beta_cluster %}
{% if autopilot_cluster != true %}
Expand Down Expand Up @@ -823,12 +828,6 @@ variable "enable_pod_security_policy" {
default = false
}

variable "enable_l4_ilb_subsetting" {
type = bool
description = "Enable L4 ILB Subsetting on the cluster"
default = false
}

variable "sandbox_enabled" {
type = bool
description = "(Beta) Enable GKE Sandbox (Do not forget to set `image_type` = `COS_CONTAINERD` to use it)."
Expand Down
1 change: 1 addition & 0 deletions autogen/safer-cluster/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ module "gke" {
monitoring_service = var.monitoring_service

monitoring_enable_managed_prometheus = var.monitoring_enable_managed_prometheus
monitoring_enabled_components = var.monitoring_enabled_components

// We never use the default service account for the cluster. The default
// project/editor permissions can create problems if nodes were to be ever
Expand Down
6 changes: 6 additions & 0 deletions autogen/safer-cluster/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ variable "monitoring_enable_managed_prometheus" {
default = false
}

variable "monitoring_enabled_components" {
type = list(string)
description = "List of services to monitor: SYSTEM_COMPONENTS, WORKLOADS. Empty list is default GKE configuration."
default = []
}

variable "grant_registry_access" {
type = bool
description = "Grants created cluster-specific service account storage.objectViewer role."
Expand Down
25 changes: 25 additions & 0 deletions cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ resource "google_container_cluster" "primary" {

enable_kubernetes_alpha = var.enable_kubernetes_alpha
enable_tpu = var.enable_tpu

enable_l4_ilb_subsetting = var.enable_l4_ilb_subsetting
dynamic "master_authorized_networks_config" {
for_each = local.master_authorized_networks_config
content {
Expand All @@ -162,6 +164,15 @@ resource "google_container_cluster" "primary" {
}
}

dynamic "node_pool_auto_config" {
for_each = var.cluster_autoscaling.enabled && length(var.network_tags) > 0 ? [1] : []
content {
network_tags {
tags = var.network_tags
}
}
}

master_auth {
client_certificate_config {
issue_client_certificate = var.issue_client_certificate
Expand Down Expand Up @@ -558,6 +569,13 @@ resource "google_container_node_pool" "pools" {
disk_type = lookup(each.value, "disk_type", "pd-standard")


dynamic "local_nvme_ssd_block_config" {
for_each = lookup(each.value, "local_nvme_ssd_count", 0) > 0 ? [1] : []
content {
local_ssd_count = local_nvme_ssd_block_config.value
}
}

service_account = lookup(
each.value,
"service_account",
Expand Down Expand Up @@ -767,6 +785,13 @@ resource "google_container_node_pool" "windows_pools" {
disk_type = lookup(each.value, "disk_type", "pd-standard")


dynamic "local_nvme_ssd_block_config" {
for_each = lookup(each.value, "local_nvme_ssd_count", 0) > 0 ? [1] : []
content {
local_ssd_count = local_nvme_ssd_block_config.value
}
}

service_account = lookup(
each.value,
"service_account",
Expand Down
2 changes: 1 addition & 1 deletion examples/deploy_service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ resource "kubernetes_pod" "nginx-example" {

spec {
container {
image = "nginx:1.25.3"
image = "nginx:1.25.4"
name = "nginx-example"
}
}
Expand Down
38 changes: 38 additions & 0 deletions examples/island_cluster_with_vm_router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# GKE island cluster using VM as router

This example provisions a cluster in an island VPC allowing reuse of the IP address space for multiple clusters in the same project.

1. An appliance(VM as router) with multiple NICs is used to establish connectivity between the island VPC and the existing network.
1. Outbound connections will go through the router.
1. For inbound connections, use Private Service Connect.

## Deploy

1. Update `project_id`, `cluster_name` and `primary_subnet` values in `terraform.tfvars`, and update other variables as needed.
1. Run `terraform apply`.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| cluster\_name | n/a | `string` | n/a | yes |
| 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 }))` | n/a | yes |
| node\_locations | n/a | `list(string)` | n/a | yes |
| primary\_net\_cidrs | n/a | `list(string)` | n/a | yes |
| primary\_subnet | n/a | `string` | n/a | yes |
| project\_id | n/a | `string` | n/a | yes |
| proxy\_subnet\_cidr | n/a | `string` | n/a | yes |
| psc\_subnet\_cidr | n/a | `string` | n/a | yes |
| region | n/a | `string` | n/a | yes |
| router\_machine\_type | n/a | `string` | n/a | yes |
| secondary\_ranges | n/a | `map(string)` | n/a | yes |
| subnet\_cidr | n/a | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| cluster\_id | n/a |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Loading

0 comments on commit 2ae62a3

Please sign in to comment.