Skip to content

Commit 29ee2ad

Browse files
author
Florencia Comuzzi
committed
create cluster
1 parent 93088b4 commit 29ee2ad

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

main.tf

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resource "google_compute_network" "vpc_network" {
1+
resource "google_compute_network" "default" {
22
name = var.vpc_name
33
auto_create_subnetworks = false
44
enable_ula_internal_ipv6 = true
@@ -13,7 +13,7 @@ resource "google_compute_subnetwork" "default" {
1313
stack_type = "IPV4_IPV6"
1414
ipv6_access_type = "INTERNAL" # Change to "EXTERNAL" if creating an external loadbalancer
1515

16-
network = google_compute_network.vpc_network.id
16+
network = google_compute_network.default.id
1717
secondary_ip_range {
1818
range_name = "services-range"
1919
ip_cidr_range = "192.168.0.0/24"
@@ -23,4 +23,25 @@ resource "google_compute_subnetwork" "default" {
2323
range_name = "pod-ranges"
2424
ip_cidr_range = "192.168.1.0/24"
2525
}
26+
}
27+
28+
resource "google_container_cluster" "default" {
29+
name = var.cluster_name
30+
31+
location = var.region
32+
enable_autopilot = true
33+
enable_l4_ilb_subsetting = true
34+
35+
network = google_compute_network.default.id
36+
subnetwork = google_compute_subnetwork.default.id
37+
38+
ip_allocation_policy {
39+
stack_type = "IPV4_IPV6"
40+
services_secondary_range_name = google_compute_subnetwork.default.secondary_ip_range[0].range_name
41+
cluster_secondary_range_name = google_compute_subnetwork.default.secondary_ip_range[1].range_name
42+
}
43+
44+
# Set `deletion_protection` to `true` will ensure that one cannot
45+
# accidentally delete this instance by use of Terraform.
46+
deletion_protection = false
2647
}

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ variable "region" {
1919
variable "vpc_name" {
2020
type = string
2121
description = "VPC network name"
22+
}
23+
24+
variable "cluster_name" {
25+
type = string
26+
description = "GKE cluster name"
2227
}

variables/dev.auto.tfvars

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
project_id = "florenciacomuzzi"
22
region = "us-east1"
3-
vpc_name = "florenciacomuzzi-vpc-dev"
3+
vpc_name = "florenciacomuzzi-vpc-dev"
4+
cluster_name = "florenciacomuzzi-cluster-dev"

variables/prod.auto.tfvars

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
project_id = "florenciacomuzzi"
22
region = "us-east1"
3-
vpc_name = "prod"
3+
vpc_name = "prod"
4+
cluster_name = "florenciacomuzzi-cluster-prod"

0 commit comments

Comments
 (0)