The AppDev Tech Field Day Report: GCP Cloud Run Demo and a GKE Comparison
Google Cloud Platform (GCP) has tried to distinguish itself by providing services tailored to diverse needs, with particular attention to cloud native and serverless. Among those technologies, Cloud Run and Google Kubernetes Engine (GKE) stand out as a pair of powerful tools for deploying containerized applications.
But why does GCP have two offerings for deploying containerized applications? They seem to compete.
At the first AppDev Field Day in Santa Clara on May 29th, I asked a team from Google Cloud and my fellow delegates about the issue.
As it turns out, Cloud Run and GKE are actually two different offerings aimed at two different user audiences. For clarification, let’s first examine a brief GCP Cloud Run demo and then contrast it with GKE, highlighting the differences and GCP’s suggested use cases.
Introduction to GCP Cloud Run
GCP Cloud Run is a fully managed serverless platform that enables developers to run stateless containers directly. It seeks to abstract away the complexities of infrastructure management so developers can focus on writing code. Cloud Run is built on Knative, an open source project that provides components for building and deploying container-based serverless applications.
Let’s start with Google’s own overviews of the Cloud Run features:
- Fully managed: Cloud Run handles infrastructure provisioning, scaling and management automatically
- Fast deployment: Deploy containerized applications in seconds with minimal configuration
- Scalability: Automatically scales from zero to thousands of container instances based on traffic
- Cost efficiency: Pay only for the resources used during request processing
- Flexibility: Supports any programming language, library, or binary.
Demo: Deploying a Container on Cloud Run
What does it take to use it? Let’s walk through a simple demonstration of deploying a containerized application on Cloud Run.
1. Prepare the Application
First, ensure you have a containerized application. For this demo, we use a simple Node.js application.
```javascript // app.js const express = require('express'); const app = express(); const port = process.env.PORT || 8080; app.get('/', (req, res) => { res.send('Hello, Cloud Run!'); }); app.listen(port, () => { console.log(`App listening on port ${port}`); }); ```
2. Containerize the Application
Create a Dockerfile to containerize the application.
```Dockerfile # Dockerfile FROM node:14 WORKDIR /usr/src/app COPY package*.json ./ RUN npm install COPY . . CMD ["node", "app.js"] ```
3. Build and Push the Container
Use the following commands to build and push the container image to Google Container Registry (GCR).
```bash gcloud auth configure-docker docker build -t gcr.io/[PROJECT-ID]/cloud-run-demo . docker push gcr.io/[PROJECT-ID]/cloud-run-demo ```
4. Deploy to Cloud Run
Deploy the container image to Cloud Run.
```bash gcloud run deploy --image gcr.io/[PROJECT-ID]/cloud-run-demo --platform managed --region [REGION] --allow-unauthenticated ```
Once deployed, Cloud Run provides a URL where the application is accessible.
Comparing Cloud Run with GKE
You’re probably familiar with the basics of GKE already, at least at a high level, simply because so much has been written about it. If not, this GKE video primer can bring you up to speed.
Among its features and benefits:
- Kubernetes orchestration: Full control over Kubernetes clusters
- Customizability: Extensive customization and configuration options
- Persistent storage: Supports stateful applications with persistent storage
Suitable GKE use cases:
- Enterprise applications: Run complex, multi-service applications with intricate networking and storage requirements
- CI/CD pipelines: Use GKE for running continuous integration and delivery pipelines
- Machine learning: Deploy machine learning models and frameworks requiring custom configurations
Cloud Run stresses its ease of use for deploying containers, primarily for developers rather than for the platform engineering crowd. I worried that the emphasis on developer needs makes it too easy for shadow IT to become a factor in the organization. Will Cloud Run make it too easy for developers to move without the rest of the team on board? Or does it put too much of a burden on the developer, where Operations should bear some responsibility?
Suitable Cloud Run use cases:
- Web applications: Deploy lightweight web applications quickly.
- APIs and microservices: Deploying stateless APIs and microservices.
- Event-driven processing: Handle background tasks and event-driven workloads efficiently.
Google Kubernetes Engine (GKE) is tuned for more complicated needs. As a more flexible platform. It appeals more to power users such as platform engineering teams – or so the GCP people appear to believe.
Different Tools, Different Needs
Cloud Run is meant for developers who want a simple tool to get the job done – what we’d have called Wizards back in the day – and GKE is for people who need and want a lot of knobs to turn and blinking lights. We all appreciate simplicity, but sometimes our needs require more advanced features that say, “Sorry kid, you need the expensive version that requires more skill and training.”
GCP Cloud Run and GKE are both powerful tools that cater to different needs. Cloud Run offers simplicity and serverless execution for stateless applications, while GKE provides the flexibility and control needed for more complex deployments. Cloud Run may be favored by developers, while GKE is more suited to full on platform engineering teams and larger development organizations.
It will be interesting to see how these two offerings develop over the coming months and years. Do they grow apart or converge into one offering with different branches for different deployment missions? Between its Gen AI offering and its cloud-native container/serverless offerings, GCP is trying to stake its own turf in the cloud wars.