Coder Social home page Coder Social logo

gke-terraform's Introduction

Example GKE cluster using Terraform

This repository showcases using Terraform to provision a new network and a GKE cluster with nodes within.

By default, this will create a highly available cluster using a NAT gateway for outgoing traffic from private nodes.

See a high level overview of the GKE architecture.

Install and configure

Ensure that kubectl, gcloud, and terraform are installed first.

Ensure the Google Cloud CLI tools are initalised:

gcloud init

Once initialised, ensure your account is added to the Application Default Credentials (ADC) so Terraform can access them:

gcloud auth application-default login

Setup variables

In terraform.tfvars set the details according to your Google Cloud account.

project_id, location, and name are required to be set.

location can be set to a region or zone. See regional or zone specific cluster docs for more information.

An example terraform.tfvars file of using a single zone cluster with preemptible nodes:

project_id         = "my-project-123"
location           = "australia-southeast1-a"
name               = "mycluster"
node_type          = "n1-standard-1"
node_disk_type     = "pd-standard"
node_disk_size_gb  = 40
node_preemptible   = true
initial_node_count = 1
min_node_count     = 1
max_node_count     = 2

Check out a list of Google Cloud regions and zones for reference.

Provisioning

terraform init
terraform apply

Configure kubectl

Retrieve the cluster name and location using terraform show, then initialise kubectl configuration:

gcloud container clusters get-credentials mycluster --region australia-southeast1-a

Test it works

kubectl get nodes -o wide

Tearing down

terraform destroy

What now?

Check out google_container_cluster Terraform docs for more details on what GKE parameters can be changed using Terraform.

Some other things:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.