GithubHelp home page GithubHelp logo

react-gke's Introduction

React App on Google Kubernetes Engine (GKE)

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

Referencing this GCP documentation

Pre-requisites

gcloud components install kubectl # installs the kubectl CLI tool

Build/Push the Docker image

  • Create a GCP project. Then, run the following commands:
docker build -t gcr.io/<your_project_id>/gcp-k8-react-app:v1 . # builds the Docker image
docker run --rm -p 8080:8080 gcr.io/<your_project_id>/gcp-k8-react-app:v1 # runs the image in a container at http://localhost:8080/
gcloud auth configure-docker # configure Docker CLI tool to authenticate with Container Registry
docker push gcr.io/<your_project_id>/gcp-k8-react-app:v1 # pushes image to Container Registry!

Deploy app to GKE

  • Create a GKE cluster:
gcloud config set project <your_project_id> # set your gcloud project ID
gcloud config set compute/zone europe-west2-a # set your gcloud compute zone
gcloud container clusters create gcp-k8-react-cluster # create a GKE cluster
gcloud container clusters get-credentials gcp-k8-react-cluster --zone europe-west2-a --project <your_project_id> # set your local kubectl command to run against the GKE environment
  • Create a deployment:
kubectl create deployment gcp-k8-react-cluster --image=gcr.io/<your_project_id>/gcp-k8-react-app:v1 # creates a deployment
kubectl expose deployment gcp-k8-react-cluster --name=gcp-k8-react-app-service --type=LoadBalancer --port 80 --target-port 8080 # exposes the deployment via a load balancer
kubectl get service # lists services. Find app URL in EXTERNAL-IP
  • Clean-up:
kubectl delete service gcp-k8-react-app-service # deletes service
gcloud container clusters delete gcp-k8-react-cluster # deletes cluster
gcloud container images delete gcr.io/<your_project_id>/gcp-k8-react-app:v1  --force-delete-tags --quiet # deletes image

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

react-gke's People

Stargazers

 avatar

Watchers

 avatar  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.