yamaceay / ratingservice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build instructions (copied from microservices-demo development guide)

Prerequisites

  • Docker for Desktop.
  • kubectl (can be installed via gcloud components install kubectl)
  • skaffold 2.0+ (latest version recommended), a tool that builds and deploys Docker images in bulk.
  • A Google Cloud Project with Google Container Registry enabled.
  • Enable GCP APIs for Cloud Monitoring, Tracing, Profiler:
gcloud services enable monitoring.googleapis.com \
    cloudtrace.googleapis.com \
    cloudprofiler.googleapis.com
  • Minikube (optional - see Local Cluster)
  • Kind (optional - see Local Cluster)

Option 1: Google Kubernetes Engine (GKE)

đź’ˇ Recommended if you're using Google Cloud Platform and want to try it on a realistic cluster. Note: If your cluster has Workload Identity enabled, see these instructions

  1. Create a Google Kubernetes Engine cluster and make sure kubectl is pointing to the cluster.

    gcloud services enable container.googleapis.com
    gcloud container clusters create demo --enable-autoupgrade \
        --enable-autoscaling --min-nodes=3 --max-nodes=10 --num-nodes=5 --zone=us-central1-a
    kubectl get nodes
    
  2. Enable Google Container Registry (GCR) on your GCP project and configure the docker CLI to authenticate to GCR:

    gcloud services enable containerregistry.googleapis.com
    gcloud auth configure-docker -q
  3. In the root of this repository, run skaffold run --default-repo=gcr.io/[PROJECT_ID], where [PROJECT_ID] is your GCP project ID.

    This command:

    • builds the container images
    • pushes them to GCR
    • applies the ./kubernetes-manifests deploying the application to Kubernetes.

    Troubleshooting: If you get "No space left on device" error on Google Cloud Shell, you can build the images on Google Cloud Build: Enable the Cloud Build API, then run skaffold run -p gcb --default-repo=gcr.io/[PROJECT_ID] instead.

  4. Find the IP address of your application, then visit the application on your browser to confirm installation.

    kubectl get service frontend-external
    
  5. Do not forget to delete the cluster after testing :)

     gcloud container clusters delete demo --zone=us-central1-a
    

Option 2 - Local Cluster

  1. Launch a local Kubernetes cluster with one of the following tools:

    • To launch Minikube (tested with Ubuntu Linux). Please, ensure that the local Kubernetes cluster has at least:

      • 4 CPUs
      • 4.0 GiB memory
      • 32 GB disk space
      minikube start --cpus=4 --memory 4096 --disk-size 32g
    • To launch Docker for Desktop (tested with Mac/Windows). Go to Preferences:

      • choose “Enable Kubernetes”,
      • set CPUs to at least 3, and Memory to at least 6.0 GiB
      • on the "Disk" tab, set at least 32 GB disk space
    • To launch a Kind cluster:

      kind create cluster
  2. Run kubectl get nodes to verify you're connected to the respective control plane.

  3. Run skaffold run (first time will be slow, it can take ~20 minutes). This will build and deploy the application. If you need to rebuild the images automatically as you refactor the code, run skaffold dev command.

  4. Run kubectl get pods to verify the Pods are ready and running.

  5. Run kubectl port-forward deployment/frontend 8080:8080 to forward a port to the frontend service.

  6. Navigate to localhost:8080 to access the web frontend.

Cleanup

If you've deployed the application with skaffold run command, you can run skaffold delete to clean up the deployed resources.

About

License:Apache License 2.0


Languages

Language:Go 29.2%Language:Python 29.0%Language:HTML 9.2%Language:C# 7.1%Language:Dockerfile 5.8%Language:Shell 5.0%Language:CSS 4.6%Language:JavaScript 4.2%Language:Java 3.4%Language:HCL 2.4%