Skip to content

Commit

Permalink
Add network_policy to google_container_cluster
Browse files Browse the repository at this point in the history
This fixes the issue with the network_policy_config starting as
disabled.

hashicorp/terraform-provider-google#3673
  • Loading branch information
aaron-lane committed Jun 5, 2019
1 parent 64399df commit 9bee256
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| 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 | string | `"false"` | no |
| network\_policy\_provider | The network policy provider. | string | `"PROVIDER_UNSPECIFIED"` | no |
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | string | `""` | no |
| node\_pools | List of maps containing node pools | list | `<list>` | no |
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
Expand Down
8 changes: 7 additions & 1 deletion autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ resource "google_container_cluster" "primary" {
region = "${var.region}"
node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"]

network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"

network_policy {
enabled = "${var.network_policy}"
provider = "${var.network_policy_provider}"
}

subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
min_master_version = "${local.kubernetes_version_regional}"

Expand Down
8 changes: 7 additions & 1 deletion autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ resource "google_container_cluster" "zonal_primary" {
zone = "${var.zones[0]}"
node_locations = ["${slice(var.zones,1,length(var.zones))}"]

network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"

network_policy {
enabled = "${var.network_policy}"
provider = "${var.network_policy_provider}"
}

subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
min_master_version = "${local.kubernetes_version_zonal}"

Expand Down
5 changes: 5 additions & 0 deletions autogen/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ variable "network_policy" {
default = false
}

variable "network_policy_provider" {
description = "The network policy provider."
default = "PROVIDER_UNSPECIFIED"
}

variable "maintenance_start_time" {
description = "Time window specified for daily maintenance operations in RFC3339 format"
default = "05:00"
Expand Down
8 changes: 7 additions & 1 deletion cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ resource "google_container_cluster" "primary" {
region = "${var.region}"
node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"]

network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"

network_policy {
enabled = "${var.network_policy}"
provider = "${var.network_policy_provider}"
}

subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
min_master_version = "${local.kubernetes_version_regional}"

Expand Down
8 changes: 7 additions & 1 deletion cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ resource "google_container_cluster" "zonal_primary" {
zone = "${var.zones[0]}"
node_locations = ["${slice(var.zones,1,length(var.zones))}"]

network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"

network_policy {
enabled = "${var.network_policy}"
provider = "${var.network_policy_provider}"
}

subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
min_master_version = "${local.kubernetes_version_zonal}"

Expand Down
1 change: 1 addition & 0 deletions modules/private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ In either case, upgrading to module version `v1.0.0` will trigger a recreation o
| 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 | string | `"false"` | no |
| network\_policy\_provider | The network policy provider. | string | `"PROVIDER_UNSPECIFIED"` | no |
| network\_project\_id | The project ID of the shared VPC's host (for shared vpc support) | string | `""` | no |
| node\_pools | List of maps containing node pools | list | `<list>` | no |
| node\_pools\_labels | Map of maps containing node labels by node-pool name | map | `<map>` | no |
Expand Down
8 changes: 7 additions & 1 deletion modules/private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ resource "google_container_cluster" "primary" {
region = "${var.region}"
node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"]

network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"

network_policy {
enabled = "${var.network_policy}"
provider = "${var.network_policy_provider}"
}

subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
min_master_version = "${local.kubernetes_version_regional}"

Expand Down
8 changes: 7 additions & 1 deletion modules/private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ resource "google_container_cluster" "zonal_primary" {
zone = "${var.zones[0]}"
node_locations = ["${slice(var.zones,1,length(var.zones))}"]

network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"
network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}"

network_policy {
enabled = "${var.network_policy}"
provider = "${var.network_policy_provider}"
}

subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}"
min_master_version = "${local.kubernetes_version_zonal}"

Expand Down
5 changes: 5 additions & 0 deletions modules/private-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ variable "network_policy" {
default = false
}

variable "network_policy_provider" {
description = "The network policy provider."
default = "PROVIDER_UNSPECIFIED"
}

variable "maintenance_start_time" {
description = "Time window specified for daily maintenance operations in RFC3339 format"
default = "05:00"
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ variable "network_policy" {
default = false
}

variable "network_policy_provider" {
description = "The network policy provider."
default = "PROVIDER_UNSPECIFIED"
}

variable "maintenance_start_time" {
description = "Time window specified for daily maintenance operations in RFC3339 format"
default = "05:00"
Expand Down

0 comments on commit 9bee256

Please sign in to comment.