- Sonic Server: A gRPC server that handles product search and order processing.
- Main Application: A web application that provides the user interface for browsing products and placing orders.
- Nginx: A reverse proxy server that routes requests to the main application and Sonic server.
- MongoDB: A NoSQL database for storing product and order data.
# Build images replace `nieltran` with your Docker Hub org or username
docker build -t nieltran/main-app:v1.0 main-app
docker build -t nieltran/sonic-server:v1.0 sonic-server
# Build and push to registry
docker push nieltran/main-app:v1.0
docker push nieltran/sonic-server:v1.0# First, copy and customize the template with your actual credentials
cp kubernetes/create-secrets.template.sh kubernetes/create-secrets.sh- Then edit
kubernetes/create-secrets.shto include your actual MongoDB URL credentials and any other sensitive data.
# Then, run the script to create the secrets file
bash kubernetes/create-secrets.sh- Install Docker: Follow the official Docker installation guide for your operating system.
- Install gcloud SDK: Follow the official Google Cloud SDK installation guide.
- Make sure you have a Google Cloud account and have created a project.
- After installed, init, auth we gonna use Terraform to create VM instances
- Install Terraform: Follow the official Terraform installation guide
- cd to terraform directory
cd terraform- run the following commands to create VM instances
terraform init # Initialize the Terraform configuration
terraform plan # Review the plan to see what resources will be created
terraform apply # Apply the configuration to create the resourcesFor detailed instructions on setting up Kubernetes on VM instances, please refer to the Kubernetes Cluster Installation Guide.
- Run the following command to deploy the application:
kubectl apply -f kubernetes/- This command will create all the necessary resources in your Kubernetes cluster, including deployments, services, and ingress rules.
Run this code on the load balancer VM to set up a nginx load balancer that will forward traffic to the ingress controller nginx-LB-setup.
➜ kubectl get svc
# Expected output:
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
# kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 5h8m
# main-app ClusterIP 10.105.112.109 <none> 80/TCP 116m
# nginx ClusterIP 10.99.130.150 <none> 80/TCP 116m
# sonic-server ClusterIP 10.110.221.120 <none> 50051/TCP 116mkubectl get pods
# All pods should be Running
# Check specific pod status
kubectl rollout status deployment/sonic-server-deployment
kubectl rollout status deployment/main-app-deployment
kubectl rollout status deployment/nginx-deployment# Execute into a pod for debugging
kubectl exec -it <pod-name> -- /bin/sh