Last active
April 30, 2019 23:35
-
-
Save diversario/e36b4d51985648b1703ed7c7c4f8cad7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "google-beta" { | |
project = "${var.project_id}" | |
region = "${var.region}" | |
credentials = "${file("~/.gcloud/my-project-terraform.json")}" | |
} | |
variable "project_id" { | |
default = "my-project" | |
description = "GCP project ID" | |
} | |
variable "vpc_name" { | |
default = "diversario-test-2" | |
description = "VPC for the cluster" | |
} | |
variable "cluster_name" { | |
default = "diversario-test-2" | |
description = "GKE cluster name" | |
} | |
variable "region" { | |
default = "us-west2" | |
description = "GKE cluster location" | |
} | |
variable "min_master_version" { | |
default = "1.11.9-gke.8" | |
} | |
resource "google_compute_network" "vpc_network" { | |
name = "${var.vpc_name}" | |
auto_create_subnetworks = false | |
routing_mode = "REGIONAL" | |
project = "${var.project_id}" | |
} | |
resource "google_container_cluster" "gke-cluster" { | |
provider = "google-beta" | |
network = "${google_compute_network.vpc_network.name}" | |
location = "${var.region}" | |
name = "${var.cluster_name}" | |
initial_node_count = 1 | |
ip_allocation_policy { | |
use_ip_aliases = true | |
create_subnetwork = true | |
node_ipv4_cidr_block = "10.160.0.0/21" | |
cluster_ipv4_cidr_block = "10.160.8.0/21" | |
services_ipv4_cidr_block = "10.160.16.0/21" | |
} | |
master_authorized_networks_config { | |
cidr_blocks = [ | |
{ | |
cidr_block = "1.1.1.1/32" # redacted, a public IP | |
display_name = "VPN" | |
} | |
] | |
} | |
private_cluster_config { | |
enable_private_endpoint = false | |
enable_private_nodes = true | |
master_ipv4_cidr_block = "172.16.0.0/28" | |
} | |
min_master_version = "${var.min_master_version}" | |
lifecycle = { | |
ignore_changes = ["node_pool"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment