Deploying Spring Boot on Google Cloud Platform

Google Cloud Platform (GCP) offers multiple managed and containerized solutions to deploy Spring Boot applications at scale. Whether you prefer App Engine (PaaS), Cloud Run (serverless), or GKE (Kubernetes), GCP has you covered.

In this post, we’ll cover three ways to deploy a Spring Boot app on GCP:

  1. App Engine Standard
  2. Cloud Run with Docker
  3. Kubernetes Engine (GKE)

We’ll use com.kscodes.springboot.containers as our sample package for all examples.

Deploying Spring Boot on Google Cloud Platform

🧰 Prerequisites

Before starting:

  • A GCP project with billing enabled
  • gcloud CLI installed and authenticated
  • Docker installed (for Cloud Run and GKE)
  • Maven or Gradle build system
  • A basic Spring Boot app (.jar or Docker)

1️⃣ Deploying to App Engine Standard

App Engine is a fully managed platform. No infrastructure to manage—just deploy.

🛠️ Step 1: Prepare Your Spring Boot App

Ensure your app listens on port 8080:

📁 Step 2: Add app.yaml

📦 Step 3: Deploy to App Engine

Package your app:

Deploy:

Visit:

2️⃣ Deploying to Cloud Run (Serverless Containers)

Cloud Run allows containerized apps to run with auto-scaling and pay-per-use pricing.

🐳 Step 1: Dockerfile

⚙️ Step 2: Build and Push Container

🚀 Step 3: Deploy to Cloud Run

Access URL provided after deploy.

3️⃣ Deploying to Google Kubernetes Engine (GKE)

GKE gives full control over Kubernetes deployments.

🧱 Step 1: Enable GKE & Create Cluster

🐳 Step 2: Docker Build and Push

📄 Step 3: Kubernetes Deployment YAML

🌐 Step 4: Expose via LoadBalancer

⚖️ Which Option to Choose?

GCP ServiceIdeal ForNotes
App EngineZero-infra PaaSLimited customization
Cloud RunServerless + containerized appsAuto-scaling, per-request billing
GKEFull control with KubernetesRequires cluster management

✅ Summary

In this tutorial, you learned how to deploy Spring Boot on Google Cloud Platform using App Engine, Cloud Run, and GKE. Each service offers a different trade-off between simplicity and control.

You now have three GCP-native ways to run your Spring Boot microservices in production with reliability and scalability.