Skip to content

Commit

Permalink
GKE 101: added guest_accelerator feature and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkonkin committed Jun 3, 2019
1 parent cf2c57e commit 8be6a89
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
5 changes: 5 additions & 0 deletions cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,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 @@ -137,6 +137,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
20 changes: 11 additions & 9 deletions examples/node_pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ module "gke" {
auto_upgrade = true
},
{
name = "pool-02"
machine_type = "n1-standard-2"
min_count = 1
max_count = 2
disk_size_gb = 30
disk_type = "pd-standard"
image_type = "COS"
auto_repair = false
service_account = "${var.compute_engine_service_account}"
name = "pool-02"
machine_type = "n1-standard-2"
min_count = 1
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
15 changes: 15 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,9 @@
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"
describe command("gcloud --project=#{project_id} container clusters --zone=#{location} describe #{cluster_name} --format=json") do
Expand Down Expand Up @@ -201,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 8be6a89

Please sign in to comment.