Skip to content

Commit

Permalink
[#2556] Working on terraform gke
Browse files Browse the repository at this point in the history
  • Loading branch information
bilge-cakmak committed Aug 25, 2022
1 parent 7154b30 commit db446fd
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 121 deletions.
13 changes: 13 additions & 0 deletions infrastructure/terraform/install/gcp-gke/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# airy.co GKS terraform installation source

### Title

The current referenced project link is ;


https://github.com/hashicorp/learn-terraform-provision-gke-cluster

```
$ some code
```

11 changes: 11 additions & 0 deletions infrastructure/terraform/install/gcp-gke/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module "gcp-gke" {
#source = "github.com/airyhq/airy.git/infrastructure/terraform/modules/gcp-gke"
source = "/Users/bilge/Documents/AiryProjects/airy/infrastructure/terraform/modules/gcp-gke"


project_id = var.project_id
region = var.region


#kubeconfig_output_path = "../kube.conf"
}
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions infrastructure/terraform/install/gcp-gke/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "project_id" {
description = "The project is airy-core-gke"
}

variable "region" {
description = "The region is us-central1"
}
10 changes: 0 additions & 10 deletions infrastructure/terraform/install/google/README.md

This file was deleted.

111 changes: 0 additions & 111 deletions infrastructure/terraform/install/google/main.tf

This file was deleted.

61 changes: 61 additions & 0 deletions infrastructure/terraform/modules/gcp-gke/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
provider "google" {
project = var.project_id
region = var.region
}

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

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


# GKE cluster
resource "google_container_cluster" "primary" {
name = "${var.project_id}-gke"
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

network = google_compute_network.vpc.name
subnetwork = google_compute_subnetwork.subnet.name
}

# Separately Managed Node Pool
resource "google_container_node_pool" "primary_nodes" {
name = "${google_container_cluster.primary.name}-node-pool"
location = var.region
cluster = google_container_cluster.primary.name
node_count = var.gke_num_nodes

node_config {
oauth_scopes = [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]

labels = {
env = var.project_id
}

# preemptible = true
machine_type = "n1-standard-1"
tags = ["gke-node", "${var.project_id}-gke"]
metadata = {
disable-legacy-endpoints = "true"
}
}
}

22 changes: 22 additions & 0 deletions infrastructure/terraform/modules/gcp-gke/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
output "kubernetes_endpoint" {
sensitive = true
value = module.gke_auth.host
}

output "client_token" {
sensitive = true
value = module.gke_auth.token
}

output "ca_certificate" {
value = module.gke_auth.cluster_ca_certificate
}

output "kubeconfig_raw" {
value = module.gke_auth.kubeconfig_raw
}

output "service_account" {
description = "The default service account used for running nodes."
value = module.gke.service_account
}
22 changes: 22 additions & 0 deletions infrastructure/terraform/modules/gcp-gke/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
variable "project_id" {
description = "The project is airy-core-gke"
}

variable "region" {
description = "The region is us-central1"
}

variable "gke_username" {
default = ""
description = "gke username"
}

variable "gke_password" {
default = ""
description = "gke password"
}

variable "gke_num_nodes" {
default = 2
description = "number of gke nodes"
}

0 comments on commit db446fd

Please sign in to comment.