@@ -3,7 +3,15 @@ variable "kubernetes_version" {
33}
44
55variable "workers_count" {
6- default = " 3"
6+ default = " 1"
7+ }
8+
9+ variable "node_machine_type" {
10+ default = " e2-micro"
11+ }
12+
13+ variable "enable_alpha" {
14+ default = true
715}
816
917data "google_compute_zones" "available" {
@@ -29,25 +37,35 @@ resource "google_service_account" "default" {
2937resource "google_container_cluster" "primary" {
3038 name = " tf-acc-test-${ random_id . cluster_name . hex } "
3139 location = data. google_compute_zones . available . names [0 ]
32- initial_node_count = var. workers_count
3340 node_version = data. google_container_engine_versions . supported . latest_node_version
3441 min_master_version = data. google_container_engine_versions . supported . latest_master_version
3542
43+ // Alpha features are disabled by default and can be enabled by GKE for a particular GKE control plane version.
44+ // Creating an alpha cluster enables all alpha features by default.
45+ // Ref: https://cloud.google.com/kubernetes-engine/docs/concepts/feature-gates
46+ enable_kubernetes_alpha = var. enable_alpha
47+
3648 node_locations = [
3749 data . google_compute_zones . available . names [1 ],
3850 ]
3951
40- node_config {
41- machine_type = " n1-standard-4"
42- service_account = google_service_account. default . email
43-
44- oauth_scopes = [
45- " https://www.googleapis.com/auth/cloud-platform" ,
46- " https://www.googleapis.com/auth/compute" ,
47- " https://www.googleapis.com/auth/devstorage.read_only" ,
48- " https://www.googleapis.com/auth/logging.write" ,
49- " https://www.googleapis.com/auth/monitoring" ,
50- ]
52+ node_pool {
53+ initial_node_count = var. workers_count
54+ management {
55+ auto_repair = var. enable_alpha ? false : true
56+ auto_upgrade = var. enable_alpha ? false : true
57+ }
58+ node_config {
59+ machine_type = var. node_machine_type
60+ service_account = google_service_account. default . email
61+ oauth_scopes = [
62+ " https://www.googleapis.com/auth/cloud-platform" ,
63+ " https://www.googleapis.com/auth/compute" ,
64+ " https://www.googleapis.com/auth/devstorage.read_only" ,
65+ " https://www.googleapis.com/auth/logging.write" ,
66+ " https://www.googleapis.com/auth/monitoring" ,
67+ ]
68+ }
5169 }
5270}
5371
@@ -85,10 +103,10 @@ locals {
85103 auth-provider = {
86104 name = " gcp"
87105 config = {
88- cmd-args = " config config-helper --format=json --access-token-file=${ path . cwd } /gcptoken"
89- cmd-path = " gcloud"
106+ cmd-args = " config config-helper --format=json --access-token-file=${ path . cwd } /gcptoken"
107+ cmd-path = " gcloud"
90108 expiry-key = " {.credential.token_expiry}"
91- token-key = " {.credential.access_token}"
109+ token-key = " {.credential.access_token}"
92110 }
93111 }
94112 }
0 commit comments