Microservices with Node JS and React Exercise
Development
- Run Kubernetes cluster inside Google Cloud or on Docker Desktop
- Use Ingress Inginx Controller to access the cluster
- Streamline development code updates using Skaffold
Switch between local K8s and GKE
For running the cluster n Docker Desktop:
- Images in services must point to docker hub
- Skaffold images must be set to docker hub
- Set
build.local
topush: false
in skaffold.yaml - Ingress service host must be set a domain pointing to 127.0.0.1 by tweaked hosts config
For running on GKE
- Images must be set to
us.gcr.io/ticketings/
- Skaffold setting
googleCloudBuild
should be set toprojectId: ticketings
- Ingress service host should be set to ticketings.gc
Setup k8s cluster
- Setup Ingress controller
- Add JWT secret in the cluster
kubectl create secret generic jwt-secret --from-literal JWT_KEY=asdf
Connect kubectl to GKE from local machine
- Go to Kubernetes Engine page and select the cluster.
- Press on >_Connect to open a cloud console.
- Copy gcloud authorization command to local terminal. It will swtich local kubectl context to gcloud, e.g.
gcloud container clusters get-credentials ticketing-dev --zone europe-west3-a --project ticketings
. - Troubleshoot: Make sure gcloud is logged in.
Setup a new service
- Create a source folder
- Build an image
- Create a k8s deployment and service
- Setup routing in the ingress service
- Update skaffold config