The cheapest way to build GCP

In this article, I’ll describe the cheapest way to deploy server with GCP in a side project
tl;dr
- Deploy API server with
Cloud run
- Deploy DB server with
Cloud SQL
- Build CI/CD pipeline with
github action
andCloub build
Deploy MySQL Database server
with Cloud SQL in Google cloud platform

Cloud SQL meta
At first fill in your database meta data.
- Set instance id
- Set databse password
- MySQL version
- Region (taiwan)
- Set
single zone
The myply
mainly serves to korean users, but I selected Taiwan(asia-east1)
because of pricing issue. detail price description

Cloud SQL Status
- Select
db-f1-micro
I set a machine type to Shared core
with 1vCPU, 0.614
. This spec is called db-f1-micro
. It costs $7.665 per month, which is the cheapest spec in cloud sql
. If I calculated it in ₩
, the currency of the south korea.
$7.665 * 1300 = ₩9,964 per month
Based on Official cloud sql docs
The db-f1-micro and db-g1-small machine types aren’t included in the Cloud SQL SLA. These machine types are configured to use a shared-core CPU, and are designed to provide low-cost test and development instances only. Don’t use them for production instances.
Note: The db-f1-micro and db-g1-small machine types are not included in the Cloud SQL SLA. These machine types are designed to provide low-cost test and development instances only. Do not use them for production instances.
- Select HDD storage
- 10GB is the lowest storage size.
$0.09 per GB/month * 10GB(min) = ₩1,170 per month

Cloud SQL misc.1

Cloud SQL misc.2

Cloud SQL misc.3
So total GCP cloud SQL
database server will cost ₩ 11,134
($8.56) per month.
Buil CI/CD pipeline
with github action and
Cloud Build
Before deploy cloud run
, you should set cloud build
to apply continuous integration and continuous deployment(CICD)
.

Link with github repository
- Enable Cloud Build API (almost free)
- Enable Container analysis API (free)

Install GCP Build plugin to your repository
- Set your repository to
cloud build


Select branch to be triggered and Dockerfile locaiton
- Select branch to be triggered
- Enter Dockerfile loaction
- If you have multi phase (e.g.
local
,sandbox
,beta
,prod
) it would be useful to set dockerfile name asdockerfile.prod
.
- If you have multi phase (e.g.
|
|
Deploy API server
with Cloud run in Google cloud platform

- Select
Continuously deploy new revisions from a source repository.
- Select region as
Taiwan(asia-east1)
- Select
Cpu is only allocated during request processing
- Set number of instance (Autoscaling) (0 ~ 4)

Set Container status
- Set application server’s port number
- Set memory
128Mib
(lowest) - Set
Number of vCPUs
less than 1. - Set Execution environment to
First generation
(slower than 2nd generation)

Connect Cloud SQL instance
- Click
Connections
tab >Cloud SQL connections
>+Add Connection
button

Connect Cloud SQL instance 2
Conclusion
Through the steps so far, I have covered the cheapest way to deploy a gcp service for a side project
topic.
Now if you have followed all the steps so far, go to your github repository and merge it into the main branch.
Then the service will deployed according to the Dockerfile
you set.