-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f0871c8
Showing
7 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most | ||
# .tfvars files are managed as part of configuration and so should be included in | ||
# version control. | ||
# | ||
# example.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export TF_VAR_project=r3x-showcase-42 | ||
export PROJECT=r3x-showcase-42 | ||
export TF_VAR_region=europe-west2 | ||
export TF_VAR_credentials=/Users/ciaranroche/.gcd/rubix.json | ||
export TF_VAR_cluster_name=rubix-cluster | ||
export CLUSTER_NAME=rubix-cluster | ||
export TF_VAR_cluster_zone=europe-west2-a | ||
export CLUSTER_ZONE=europe-west2-a | ||
export TF_VAR_node_pool_name=rubix-node-pool | ||
export TF_VAR_node_pool_zone=europe-west2-a |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# RubiX GKE Terraform | ||
|
||
gcloud container clusters get-credentials |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
##################################################################### | ||
# GKE Cluster | ||
##################################################################### | ||
resource "google_container_cluster" "rubix" { | ||
name = "${var.cluster_name}" | ||
zone = "${var.cluster_zone}" | ||
initial_node_count = "${var.gcp_cluster_count}" | ||
|
||
node_config { | ||
oauth_scopes = [ | ||
"service-control", | ||
"service-management", | ||
"compute-rw", | ||
"storage-ro", | ||
"cloud-platform", | ||
"logging-write", | ||
"monitoring-write", | ||
"pubsub", | ||
"datastore" | ||
] | ||
labels { | ||
this-is-for = "dev-cluster" | ||
} | ||
tags = ["dev"] | ||
machine_type = "n1-standard-4" | ||
} | ||
} | ||
resource "google_container_node_pool" "rubix" { | ||
name = "${var.node_pool_name}" | ||
zone = "${var.node_pool_zone}" | ||
cluster = "${google_container_cluster.rubix.name}" | ||
autoscaling { | ||
min_node_count = 1 | ||
max_node_count = 10 | ||
} | ||
management { | ||
auto_repair = true | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
##################################################################### | ||
# Google Cloud Platform | ||
##################################################################### | ||
provider "google" { | ||
credentials = "${file("${var.credentials}")}" | ||
project = "${var.project}" | ||
region = "${var.region}" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
##################################################################### | ||
# General Variables | ||
##################################################################### | ||
variable "project" { | ||
type = "string" | ||
description = "Project name." | ||
} | ||
variable "region" { | ||
type = "string" | ||
description = "Region name." | ||
} | ||
variable "credentials" { | ||
type = "string" | ||
description = "Location of GCP credentials." | ||
} | ||
|
||
##################################################################### | ||
# GCP Variables | ||
##################################################################### | ||
variable "gcp_cluster_count" { | ||
type = "string" | ||
description = "Count of cluster instances to start." | ||
} | ||
variable "cluster_name" { | ||
type = "string" | ||
description = "Cluster name for the GCP Cluster." | ||
} | ||
variable "cluster_zone" { | ||
type = "string" | ||
description = "Cluster zone for the GCP Cluster." | ||
} | ||
variable "node_pool_name" { | ||
type = "string" | ||
description = "Node pool name for the GCP Cluster." | ||
} | ||
variable "node_pool_zone" { | ||
type = "string" | ||
description = "Node pool zone for the GCP Cluster." | ||
} | ||
|
||
##################################################################### | ||
# GCP Outputs | ||
##################################################################### | ||
output "gcp_cluster_name" { | ||
value = "${google_container_cluster.rubix.name}" | ||
} | ||
output "host" { | ||
value = "${google_container_cluster.rubix.endpoint}" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
##################################################################### | ||
# Variables | ||
##################################################################### | ||
variable "project" { | ||
type = "string" | ||
description = "Project name." | ||
} | ||
variable "region" { | ||
type = "string" | ||
description = "Region name." | ||
} | ||
variable "credentials" { | ||
type = "string" | ||
description = "Location of GCP credentials." | ||
} | ||
variable "gcp_cluster_count" { | ||
type = "string" | ||
description = "Count of cluster instances to start." | ||
default = 1 | ||
} | ||
variable "cluster_name" { | ||
type = "string" | ||
description = "Cluster name for the GCP Cluster." | ||
} | ||
variable "cluster_zone" { | ||
type = "string" | ||
description = "Cluster zone for the GCP Cluster." | ||
} | ||
variable "node_pool_name" { | ||
type = "string" | ||
description = "Node pool name for the GCP Cluster." | ||
} | ||
variable "node_pool_zone" { | ||
type = "string" | ||
description = "Node pool zone for the GCP Cluster." | ||
} | ||
|
||
##################################################################### | ||
# Outputs | ||
##################################################################### | ||
output "gcp_cluster_endpoint" { | ||
value = "${module.gke.host}" | ||
} | ||
output "gcp_cluster_name" { | ||
value = "${module.gke.gcp_cluster_name}" | ||
} | ||
|
||
##################################################################### | ||
# Modules | ||
##################################################################### | ||
module "gke" { | ||
source = "./gke" | ||
project = "${var.project}" | ||
region = "${var.region}" | ||
credentials = "${var.credentials}" | ||
gcp_cluster_count = "${var.gcp_cluster_count}" | ||
cluster_name = "${var.cluster_name}" | ||
cluster_zone = "${var.cluster_zone}" | ||
node_pool_name = "${var.node_pool_name}" | ||
node_pool_zone = "${var.node_pool_zone}" | ||
} |