Giter Club home page Giter Club logo

gke-using-terraform's Introduction

GKE Using Terraform

This repo explain how to create a Kubernetes cluster in GKE using terraform Infrastructure as code (IaC)

  • Prerequisites
  • Set gcloud
  • Clone this repo
  • Update the terraform.tvars file
  • Use Terraform
  • Set kubectl to work with your cluster

Prerequisites

This repo requires you to have configured:

  • a GCP account
  • a configured gcloud SDK
  • Terrafom installed
  • kubectl

Set gcloud

Initialize gcloud

gcloud init

Authorize the SDK to access GCP using your user account credentials and add the SDK to your path

gcloud auth application-default login

Set a default project for gcloud, replace with your project_id:

gcloud config set project PROJECT_ID

Clone this repo

Use git clone:

git clone https://github.com/andrescaroc/gke-using-terraform.git

Change directory:

cd gke-using-terraform

Update the terraform.tvars file

Replace the values in your terraform.tvars file with your project_id and region from your GCP account.

# terraform.tfvars
project_id = "REPLACE_ME"
region     = "REPLACE_ME_TOO"

You can find the project your gcloud is configured to with this command.

gcloud config get-value project

You can find a full list of gcloud regions here.

Use Terraform

Initialize terraform, this will install the provider plugins:

terraform init

Before continue, make sure Compute Engine API and Kubernetes Engine API are enabled in your GCP console for your project_id, if not sure visit:

And verify it is not asking you to enable the respective API.

Then, let terraform create the defined resources:

terraform apply

Set kubectl to work with your cluster

Gather and set the kubeconfig required by kubectl to manage your GKE cluster

gcloud container clusters get-credentials $(terraform output -raw kubernetes_cluster_name) --region $(terraform output -raw region)

gke-using-terraform's People

Contributors

andrescaroc avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.