Skip to content

Instantly share code, notes, and snippets.

@nathanleclaire
Last active September 21, 2018 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanleclaire/63b76ceae365010bf048f233a9a7bbfe to your computer and use it in GitHub Desktop.
Save nathanleclaire/63b76ceae365010bf048f233a9a7bbfe to your computer and use it in GitHub Desktop.
Basic setup to get a GKE cluster on Google Cloud using Terraform
variable "kube_password" {
default = "containers_r_cool"
}
variable "google_project" {
default = "honeycomb-test-project"
}
variable "google_region" {
default = "us-west1-a"
}
provider "google" {
project = "${var.google_project}"
region = "${var.google_region}"
# Need to get this using Google Cloud portal and store it here
credentials = "${file("creds.json")}"
}
resource "google_container_cluster" "primary" {
name = "primary"
zone = "${var.google_region}"
initial_node_count = 1
master_auth {
username = "nathan"
password = "${var.kube_password}"
}
node_config {
machine_type = "n1-standard-1"
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
}
# These almost assuredly should be bumped to the latest
min_master_version = "1.8.3-gke.0"
node_version = "1.8.3-gke.0"
# Will point your local Kube at this cluster
provisioner "local-exec" {
command = "gcloud container clusters get-credentials primary"
}
}
resource "google_container_node_pool" "workerpool" {
name = "workerpool"
zone = "${var.google_region}"
cluster = "${google_container_cluster.primary.name}"
node_count = 1
node_config {
machine_type = "n1-standard-1"
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment