forked from den-vasyliev/tf-google-gke-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
52 lines (44 loc) · 1.28 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
provider "google" {
# Configuration options
project = var.GOOGLE_PROJECT
region = var.GOOGLE_REGION
}
resource "google_container_cluster" "this" {
name = var.GKE_CLUSTER_NAME
location = var.GOOGLE_REGION
initial_node_count = 1
remove_default_node_pool = true
workload_identity_config {
workload_pool = "${var.GOOGLE_PROJECT}.svc.id.goog"
}
node_config {
workload_metadata_config {
mode = "GKE_METADATA"
}
}
}
resource "google_container_node_pool" "this" {
name = var.GKE_POOL_NAME
project = google_container_cluster.this.project
cluster = google_container_cluster.this.name
location = google_container_cluster.this.location
node_count = var.GKE_NUM_NODES
node_config {
machine_type = var.GKE_MACHINE_TYPE
}
}
module "gke_auth" {
depends_on = [
google_container_cluster.this
]
source = "terraform-google-modules/kubernetes-engine/google//modules/auth"
version = ">= 24.0.0"
project_id = var.GOOGLE_PROJECT
cluster_name = google_container_cluster.this.name
location = var.GOOGLE_REGION
}
resource "local_file" "kubeconfig" {
content = module.gke_auth.kubeconfig_raw
filename = "${path.module}/kubeconfig"
file_permission = "0400"
}