-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster.tf
67 lines (55 loc) · 1.82 KB
/
cluster.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# google_client_config and kubernetes provider must be explicitly specified like the following.
# Retrieve an access token as the Terraform runner
data "google_client_config" "default" {}
# GKE cluster
resource "google_container_cluster" "primary" {
name = var.cluster-name
project = var.project
location = var.region
# We can't create a cluster with no node pool defined, but we want to only use
# separately managed node pools. So we create the smallest possible default
# node pool and immediately delete it.
remove_default_node_pool = true
initial_node_count = 1
networking_mode = "VPC_NATIVE"
ip_allocation_policy {
cluster_ipv4_cidr_block = "10.44.0.0/14"
services_ipv4_cidr_block = "10.48.0.0/20"
}
#networking_mode = "VPC_NATIVE"
#ip_allocation_policy {}
}
# Separately Managed Node Pool
resource "google_container_node_pool" "primary_nodes" {
project = var.project
name = "${google_container_cluster.primary.name}-node-pool"
location = var.region
cluster = google_container_cluster.primary.name
node_count = 1
node_config {
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/cloud-platform"
]
labels = {
env = var.project
}
#preemptible = true
#machine_type = "e2-small"
#tags = ["gke-node"]
#metadata = {
# disable-legacy-endpoints = "true"
#}
}
}
module "gke_auth" {
source = "terraform-google-modules/kubernetes-engine/google//modules/auth"
version = "24.0.0"
project_id = var.project
cluster_name = google_container_cluster.primary.name
location = var.region
depends_on = [
google_container_cluster.primary
]
}