Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A Quiz
🔍 Overview
After setting up your GCP account and understanding core
services, it’s time to deploy your first real-world application. Google
Cloud makes it easy to host applications using a variety of compute
options—whether it's a static site, a containerized service, or a dynamic
backend API.
This chapter walks you through:
🧱 1. Prerequisites
Before deploying:
bash
gcloud
services enable compute.googleapis.com \
appengine.googleapis.com \
run.googleapis.com \
sqladmin.googleapis.com
\
cloudbuild.googleapis.com
🖼️ 2. Deploying a Static
Website on Cloud Storage
✅ Step-by-Step:
bash
gsutil
mb -l US gs://your-bucket-name
bash
gsutil
iam ch allUsers:objectViewer gs://your-bucket-name
bash
gsutil
web set -m index.html gs://your-bucket-name
bash
gsutil
cp index.html gs://your-bucket-name
Feature |
Value |
Storage Class |
Standard |
Access Control |
Uniform (recommended) |
Cost |
Free Tier: 5 GB/month |
🚀 3. Deploying a Dynamic
Web App with App Engine
✅ Use Case: Python Flask App
1. Create App Engine Project
bash
gcloud
app create --region=us-central
2. Sample main.py
python
from
flask import Flask
app
= Flask(__name__)
@app.route('/')
def
hello():
return 'Hello from App Engine!'
3. app.yaml
yaml
runtime:
python310
entrypoint:
gunicorn -b :$PORT main:app
handlers:
-
url: /.*
script: auto
4. Deploy
bash
gcloud
app deploy
5. Visit URL:
https://<your-project-id>.appspot.com
⚙️ 4. Deploying a Containerized
App with Cloud Run
✅ Use Case: Dockerized Node.js
App
1. Dockerfile
dockerfile
FROM
node:18
WORKDIR
/app
COPY
. .
RUN
npm install
CMD
["node", "server.js"]
2. Build Image
bash
gcloud
builds submit --tag gcr.io/your-project-id/hellorun
3. Deploy to Cloud Run
bash
gcloud
run deploy hellorun \
--image gcr.io/your-project-id/hellorun \
--platform managed \
--region us-central1 \
--allow-unauthenticated
Feature |
Benefit |
Stateless
Containers |
Automatically scale to
zero |
Bill Per Request |
Cost-effective
for infrequent usage |
HTTP URL Provided |
Auto HTTPS, custom
domains supported |
💻 5. Hosting on Compute
Engine (VM)
1. Launch a VM
bash
gcloud
compute instances create web-vm \
--zone=us-central1-a \
--machine-type=e2-micro \
--image-family=debian-11 \
--image-project=debian-cloud \
--tags=http-server
2. Install Web Server
bash
sudo
apt update
sudo
apt install apache2 -y
3. Make Web Page
bash
echo
"Hello GCP VM!" | sudo tee /var/www/html/index.html
4. Add Firewall Rule
bash
gcloud
compute firewall-rules create allow-http \
--allow tcp:80 \
--target-tags http-server
5. Visit:
http://<EXTERNAL_IP>
🗃️ 6. Connecting to
Cloud SQL from Your App
1. Create Cloud SQL Instance
bash
gcloud
sql instances create mydb \
--database-version=MYSQL_8_0 \
--tier=db-f1-micro \
--region=us-central
2. Create User & Database
bash
gcloud
sql users set-password root --host=% --instance=mydb --password=your-password
gcloud
sql databases create appdata --instance=mydb
3. Connect via App Engine (using Cloud SQL Proxy)
Add to app.yaml:
yaml
beta_settings:
cloud_sql_instances:
your-project:us-central:mydb
Use connection string in your app (Python example):
python
pymysql.connect(unix_socket='/cloudsql/your-project:us-central:mydb',
...)
📈 7. Enabling Monitoring
and Logs
1. View Logs
bash
gcloud
logging read "resource.type=gae_app"
2. Open Logs Explorer:
3. Create Uptime Checks
✅ 8. Summary Table – Deployment
Options
Method |
Use Case |
Scales
Automatically |
Management Level |
Cloud Storage |
Static websites, files |
N/A |
Fully managed |
App Engine |
Web apps with
standard runtimes |
✅ |
Fully managed |
Cloud Run |
Docker apps, APIs |
✅ |
Fully managed |
Compute Engine |
Full VM
control, legacy apps |
Manual |
Self-managed |
🎯 Final Thoughts
GCP offers multiple deployment options to suit every
need—from static websites to containerized microservices. With simple commands
and intuitive interfaces, you can launch apps in minutes and scale them
globally.
Once your app is running, make sure to monitor it using
Cloud Monitoring, optimize costs with budgets, and secure your endpoints with
IAM and firewall rules.
In the next chapter, we’ll explore IAM, billing
management, and cloud security best practices.
Answer:
GCP is Google’s suite of cloud computing services that provides infrastructure,
platform, and serverless environments to build, deploy, and scale applications
using the same technology that powers Google Search, YouTube, and Gmail.
Answer:
Yes. GCP offers a $300 free credit for 90 days for new users and an Always
Free Tier for services like Cloud Storage, BigQuery, and Compute Engine (1
f1-micro instance in select regions).
Answer:
To get started, create a Google Cloud account at cloud.google.com, set up
your first project, enable billing, and explore the Console or use the gcloud
CLI for resource management.
Answer:
Answer:
A GCP project is a container for resources like VMs, buckets, APIs, and
billing. It isolates services and permissions and helps organize workloads
across environments.
Answer:
GCP supports many languages including Python, Java, Go, Node.js, Ruby, PHP,
C#, and .NET, depending on the service used (App Engine, Cloud Functions,
Cloud Run, etc.).
Answer:
You can manage GCP via:
Answer:
BigQuery is a serverless data warehouse that allows you to store and
analyze large datasets using SQL. It’s ideal for data analytics, reporting, and
business intelligence.
Answer:
Yes. GCP offers multiple options to host websites:
Answer:
Yes. Google Cloud offers certifications like:
Please log in to access this content. You will be redirected to the login page shortly.
LoginReady to take your education and career to the next level? Register today and join our growing community of learners and professionals.
Comments(0)