Skip to content

Commit

Permalink
Merge pull request terraform-google-modules#197 from marko7460/add_gu…
Browse files Browse the repository at this point in the history
…est_accelerator

Adding back guest_accelerator
  • Loading branch information
morgante committed Jun 27, 2019
2 parents 0c30bf5 + 7dc19ff commit d1fc431
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 2 deletions.
5 changes: 5 additions & 0 deletions autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ resource "google_container_node_pool" "pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ resource "google_container_node_pool" "zonal_pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ resource "google_container_node_pool" "pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ resource "google_container_node_pool" "zonal_pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
6 changes: 4 additions & 2 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ locals {
}

provider "google" {
version = "~> 2.7.0"
version = "~> 2.9.0"
region = "${var.region}"
}

provider "google-beta" {
version = "~> 2.7.0"
version = "~> 2.9.0"
region = "${var.region}"
}

Expand Down Expand Up @@ -57,6 +57,8 @@ module "gke" {
max_count = 2
disk_size_gb = 30
disk_type = "pd-standard"
accelerator_count = 1
accelerator_type = "nvidia-tesla-p4"
image_type = "COS"
auto_repair = false
service_account = "${var.compute_engine_service_account}"
Expand Down
5 changes: 5 additions & 0 deletions modules/beta-private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ resource "google_container_node_pool" "pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions modules/beta-private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ resource "google_container_node_pool" "zonal_pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions modules/beta-public-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ resource "google_container_node_pool" "pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions modules/beta-public-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ resource "google_container_node_pool" "zonal_pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions modules/private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ resource "google_container_node_pool" "pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
5 changes: 5 additions & 0 deletions modules/private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ resource "google_container_node_pool" "zonal_pools" {
"${concat(var.node_pools_oauth_scopes["all"],
var.node_pools_oauth_scopes[lookup(var.node_pools[count.index], "name")])}",
]

guest_accelerator {
type = "${lookup(var.node_pools[count.index], "accelerator_type", "")}"
count = "${lookup(var.node_pools[count.index], "accelerator_count", 0)}"
}
}

lifecycle {
Expand Down
14 changes: 14 additions & 0 deletions test/integration/node_pool/controls/gcloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
location = attribute('location')
cluster_name = attribute('cluster_name')

expected_accelerators_count = "1"
expected_accelerators_type = "nvidia-tesla-p4"

control "gcloud" do
title "Google Compute Engine GKE configuration"
Expand Down Expand Up @@ -202,6 +204,18 @@
)
end

it "has the expected accelerators" do
expect(data['nodePools']).to include(
including(
"name" => "pool-02",
"config" => including(
"accelerators" => [{"acceleratorCount" => expected_accelerators_count,
"acceleratorType" => expected_accelerators_type}],
),
)
)
end

it "has the expected disk size" do
expect(data['nodePools']).to include(
including(
Expand Down

0 comments on commit d1fc431

Please sign in to comment.