GKE ยท NGINX Ingress Controller ยท Let's Encrypt HTTPS ยท Google Container Registry ยท Cloud Build
Architecture
Exact Steps โ How I Built This
Created a new GCP project and enabled the required APIs: Kubernetes Engine API, Container Registry API, and Cloud Build API. Configured the gcloud CLI locally and authenticated with the project.
Provisioned a GKE cluster with a managed node pool. Used a standard cluster with autoscaling enabled so nodes scale based on workload demand.
Wrote a multi-stage Dockerfile โ Stage 1 uses Node.js to build the React app, Stage 2 uses lightweight Nginx Alpine to serve only the compiled output. This reduced the image from ~1.2GB to under 100MB.
Built the Docker image and pushed it to GCR โ Google's private container registry. Using GCR means GKE can pull images without any external authentication setup.
Created a Kubernetes Deployment manifest declaring 2 replicas, resource limits, and the GCR image. Applied it with kubectl. The cluster immediately pulled the image and started running pods.
Installed the NGINX Ingress Controller using Helm. This creates a GCP Load Balancer automatically and provisions an external IP address that becomes the public entry point for all traffic.
Installed cert-manager โ a Kubernetes operator that automatically requests, installs, and renews TLS certificates from Let's Encrypt. Created a ClusterIssuer resource pointing to Let's Encrypt's ACME endpoint.
Created the Ingress manifest that routes traffic from the external IP to the MoodTunes service, and instructs cert-manager to issue a Let's Encrypt certificate for the domain. HTTP automatically redirects to HTTPS.
Connected the GitHub repository to Cloud Build. Created a cloudbuild.yaml file that builds the Docker image, pushes to GCR, and triggers a Kubernetes rolling update โ automatically on every push to main.
Final verification โ checked that all pods are running healthy, the certificate is issued, and the app loads over HTTPS in a browser.
Lessons Learned
A single-stage Node.js build produces an image over 1GB. A multi-stage build with Nginx Alpine produces under 100MB. Smaller images mean faster pulls, smaller attack surface, and lower storage costs โ all for the same running application.
Creating a LoadBalancer service for every Kubernetes deployment creates one GCP load balancer per service โ expensive and unmanageable. One NGINX Ingress controller handles all external traffic and routes by hostname or path. One load balancer for everything.
Manual TLS certificate management is a reliability risk โ expired certs silently kill HTTPS. cert-manager renews Let's Encrypt certificates automatically 30 days before expiry. Once configured, you never think about certificates again.
Without CI/CD, deploying an update means manually building, tagging, pushing, and rolling out. With Cloud Build, every git push does all of that automatically in under 3 minutes. The pipeline is the deployment.