Code Monkey home page Code Monkey logo

gke-basic-cluster-deployment's Introduction

gke-basic-cluster-deployment

โœจ Deploy GKE private cluster using terraform and expose an echo server

๐Ÿ–ฑ๏ธ For Details and components explanation read A gentle introduction to GKE private cluster deployment

๐Ÿ—๏ธ For production-grade deployments see the official Terraform Kubernetes Engine Module


Deploy

Infrastructure

  • Prerequisites

  • Enable the following GCP APIs using the GCP console [1]

    • Open GCP console -> APIs & Services -> enable APIs and services
    • Enable:
      • Compute Engine API
      • Kubernetes Engine API
  • Clone the repo gke-basic-cluster-deployment

  • Compile the input variables:

        $ cp iac/variables.tfvars.example iac/variables.tfvars
        $ vi iac/variables.tfvars # replace with your data
  • Deploy the cluster:

    • Replace\set the variables with your data
        # configure gcloud to the desired project
        $ gcloud config set project $PROJECT_ID
    
        # configure terraform
        $ cd iac
        $ tfswitch
        $ terraform init
    
        # deploy the GKE pre-requisites
        $ terraform plan -out out.plan -var-file="./variables.tfvars" -var  deploy_cluster=false
        $ terraform apply out.plan
        
        # deploy GKE - can take more than 20 minutes
        $ terraform plan -out out.plan -var-file="./variables.tfvars" -var deploy_cluster=true
        $ terraform apply out.plan
  • Deploy the services into k8s

    • Replace\set the variables with your data
        # set kubectl context
        $ gcloud container clusters get-credentials gkedeploy-cluster --zone $PROJECT_REGION --project $PROJECT_ID
    
        # create common resources
        $ kubectl apply -f k8s/common
    
        # deploy the server
        $ kubectl apply -f k8s/gechoserver/
    
        # wait that the ADDRESS will be displayed - can take more than 10 minutes
        $ kubectl -n dev get ingress -o wide
        NAME          CLASS    HOSTS   ADDRESS          PORTS   AGE
        gechoserver   <none>   *       34.120.114.207   80      67s
    
        # query the server from internet - can take  more than 10 minutes
        # replace "34.120.114.207" with your address:
        $ curl -XPOST -v http://34.120.114.207/ -d "foo=bar"
    
        # ~ Congratulation, your server on GKE is up and running! ~
  • Destroy the cluster:

        $ cd iac
        $ terraform destroy -auto-approve -var-file="./variables.tfvars" -var deploy_cluster=true

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.