Git Product home page Git Product logo

gcp-react-gke-terraform's Introduction

React App on Google Kubernetes Engine (GKE) with Terraform

A reference project to deploy a React app onto Google Kubernetes Engine (GKE) with Terraform

Pre-requisites

gcloud components install kubectl # installs the kubectl CLI tool
terraform -help # prints Terraform options

Configuration

  • Populate terraform.tfvars:
region  = "europe-west2"
zone    = "europe-west2-b"
project = <GCP-PROJECT-ID>
creds   = <PATH-TO-GCP-CREDENTIALS-JSON>

Build/Push the Docker image

docker build -t gcr.io/<your_project_id>/react-gke-nginx:v1 . # builds Docker image
gcloud auth configure-docker # configure Docker CLI tool to authenticate with Container Registry
docker push gcr.io/<your_project_id>/react-gke-nginx:v1 # pushes image to Container Registry!

Create GCP resources

cd deploy # change to deploy directory
terraform init # initialises Terraform
terraform apply # deploys GCP stack
terraform destroy # destroys GCP stack

Deployment

gcloud container clusters get-credentials react-gke-cluster --region=europe-west2 # updates a kubeconfig file with appropriate credentials
cd k8s
kubectl apply -f namespace.yml # create namespace
kubectl apply -f . # create deployment, ingress, and service
kubectl delete -f . # remove resources
  • Visit app at app_ip e.g. http://34.117.202.234/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

gcp-react-gke-terraform's People

Contributors

matthewcylau avatar

Watchers

 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.