Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:adds placement policy argument to the beta modules #1385

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autogen/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ The node_pools variable takes the following parameters:
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
| name | The name of the node pool | | Required |
{% if beta_cluster %}
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
| pod_range | The ID of the secondary range for pod IPs. | | Optional |
{% endif %}
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
Expand Down
7 changes: 7 additions & 0 deletions autogen/main/cluster.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,13 @@ resource "google_container_node_pool" "pools" {
}

{% if beta_cluster %}
dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ The node_pools variable takes the following parameters:
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. | 0 | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
| name | The name of the node pool | | Required |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
| pod_range | The ID of the secondary range for pod IPs. | | Optional |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-private-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ resource "google_container_node_pool" "pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
Expand Down
1 change: 1 addition & 0 deletions modules/beta-private-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ The node_pools variable takes the following parameters:
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. | 0 | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
| name | The name of the node pool | | Required |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
| pod_range | The ID of the secondary range for pod IPs. | | Optional |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-private-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ resource "google_container_node_pool" "pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster-update-variant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ The node_pools variable takes the following parameters:
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. | 0 | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
| name | The name of the node pool | | Required |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
| pod_range | The ID of the secondary range for pod IPs. | | Optional |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-public-cluster-update-variant/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@ resource "google_container_node_pool" "pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
Expand Down
1 change: 1 addition & 0 deletions modules/beta-public-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ The node_pools variable takes the following parameters:
| max_unavailable | The number of nodes that can be simultaneously unavailable during an upgrade. Increasing max_unavailable raises the number of nodes that can be upgraded in parallel. Can be set to 0 or greater. | 0 | Optional |
| min_count | Minimum number of nodes in the NodePool. Must be >=0 and <= max_count. Should be used when autoscaling is true | 1 | Optional |
| name | The name of the node pool | | Required |
| placement_policy | Placement type to set for nodes in a node pool. Can be set as [COMPACT](https://cloud.google.com/kubernetes-engine/docs/how-to/compact-placement#overview) if desired | Optional |
| pod_range | The ID of the secondary range for pod IPs. | | Optional |
| node_count | The number of nodes in the nodepool when autoscaling is false. Otherwise defaults to 1. Only valid for non-autoscaling clusters | | Required |
| node_locations | The list of zones in which the cluster's nodes are located. Nodes must be in the region of their regional cluster or in the same region as their cluster's zone for zonal clusters. Defaults to cluster level node locations if nothing is specified | " " | Optional |
Expand Down
7 changes: 7 additions & 0 deletions modules/beta-public-cluster/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ resource "google_container_node_pool" "pools" {
}
}

dynamic "placement_policy" {
for_each = length(lookup(each.value, "placement_policy", "")) > 0 ? [each.value] : []
content {
type = lookup(placement_policy.value, "placement_policy", null)
}
}

dynamic "network_config" {
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
content {
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/beta_cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ module "this" {
ip_range_services = google_compute_subnetwork.main.secondary_ip_range[1].range_name
compute_engine_service_account = "create"

node_pools = [
{
name = "pool-01"
machine_type = "n2-standard-2"
min_count = 1
max_count = 2
auto_upgrade = true
// Beta feature
placement_policy = "COMPACT"
},
]

// Beta features
istio = true

Expand Down
18 changes: 14 additions & 4 deletions test/integration/beta_cluster/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
expect(node_pools).to include(
including(
"autoscaling" => including(
"maxNodeCount" => 100,
"maxNodeCount" => 2,
),
)
)
Expand All @@ -177,7 +177,7 @@
expect(node_pools).to include(
including(
"config" => including(
"machineType" => "e2-medium",
"machineType" => "n2-standard-2",
),
)
)
Expand All @@ -199,7 +199,7 @@
"config" => including(
"labels" => including(
"cluster_name" => cluster_name,
"node_pool" => "default-node-pool",
"node_pool" => "pool-01",
),
),
)
Expand All @@ -212,7 +212,7 @@
"config" => including(
"tags" => match_array([
"gke-#{cluster_name}",
"gke-#{cluster_name}-default-node-pool",
"gke-#{cluster_name}-pool-01",
]),
),
)
Expand All @@ -228,6 +228,16 @@
)
)
end

it "has placement policy set to COMPACT" do
expect(node_pools).to include(
including(
"placementPolicy" => including(
"type" => "COMPACT",
),
)
)
end
end
end
end