Skip to content

Commit

Permalink
Merge pull request #46 from Buildings-IOT/gcp_gke
Browse files Browse the repository at this point in the history
Created gks.tf and vpc.tf
  • Loading branch information
nkotibiot committed Mar 15, 2022
2 parents c6aef47 + d69732a commit 0284a90
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cloud/gcp/gks.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
variable "gke_num_nodes" {
type = number
default = "1"
description = "number of gke nodes"
}

#GKE CLUSTER
resource "google_container_cluster" "biot" {
name = "${var.gcp_project_id}-gke"
location = var.gcp_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
}

# Separately Managed Node Pool
resource "google_container_node_pool" "node_pool" {
name = "${var.gcp_project_id}-node-pool"
location = var.gcp_region
cluster = var.gcp_project_id
node_count = var.gke_num_nodes

node_config {
preemptible = true
machine_type = "e2-medium"
}
}
18 changes: 18 additions & 0 deletions cloud/gcp/vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
variable "gcp_vpc_name" {
type = string
description = "vpc name"
}

# VPC
resource "google_compute_network" "vpc" {
name = "${var.gcp_vpc_name}-vpc"
auto_create_subnetworks = "false"
}

# Subnet
resource "google_compute_subnetwork" "subnet" {
name = "${var.gcp_vpc_name}-subnet"
region = var.gcp_region
network = google_compute_network.vpc.name
ip_cidr_range = "10.10.0.0/24"
}

0 comments on commit 0284a90

Please sign in to comment.