Skip to content

Commit a107194

Browse files
Merge pull request #259 from DefangLabs/jordan/gcp-estimation-docs
Update estimation docs for GCP
2 parents b674b72 + d9750fd commit a107194

File tree

3 files changed

+130
-4
lines changed

3 files changed

+130
-4
lines changed

docs/concepts/estimation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ sidebar_position: 280
99
Defang enables you to estimate the cost of deploying and running your project without needing to create an account with your cloud provider.
1010

1111
:::info
12-
Currently, AWS is the only provider supported for cost estimation. Support for GCP and Digital Ocean is coming soon.
12+
Currently, AWS and GCP are supported for cost estimation. Support for Digital Ocean is coming soon.
1313
:::
1414

1515
## Generating an Estimate
1616

1717
Navigate your shell to your application's working directory and run
1818
```
19-
defang estimate [--provider aws] [--mode affordable|balanced|high_availability]
19+
defang estimate [--provider=aws|gcp] [--mode=affordable|balanced|high_availability]
2020
```
2121

22-
Here is an example of the output you would see if you estimated the cost deploying the [django-postgres](https://github.com/DefangLabs/samples/tree/main/samples/django-postgres) sample using the `balanced` [deployment mode](/docs/concepts/deployment-modes).
22+
Here is an example of the output you would see if you estimated the cost deploying the [django-postgres](https://github.com/DefangLabs/samples/tree/main/samples/django-postgres) to AWS sample using the `balanced` [deployment mode](/docs/concepts/deployment-modes).
2323

2424
```
2525
defang estimate --provider=aws --mode=balanced

docs/tutorials/estimating-aws-deployment-costs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ To estimate other modes, use defang estimate --mode=affordable|balanced|high_ava
112112
For help with warnings, check our FAQ at https://s.defang.io/warnings
113113
```
114114

115-
This estimate will include a line item for the most significant monthly costs associated with your deployment. Each line item will be associated with a compose service if possible. Some AWS resources will be shared between multiple compose services.
115+
This estimate will include a line item for the most significant monthly costs associated with your deployment. Each line item will be associated with a compose service if possible. Some resources will be shared between multiple compose services.
116116

117117
## Deploying your project
118118

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
title: Estimating GCP Deployment Costs
3+
description: Defang enables you to estimate the cost of deploying and running your project before you even create a cloud account.
4+
sidebar_position: 281
5+
---
6+
7+
# Estimating GCP Deployment Costs
8+
9+
Defang enables you to estimate the cost of deploying and running your project without needing to create an account with your cloud provider. This tutorial will walk through estimating the costs of deploying the [django-postgres](https://github.com/DefangLabs/samples/tree/main/samples/django-postgres) to GCP.
10+
11+
## Clone the sample
12+
13+
```
14+
defang generate # select `django-postgres` (or any other sample) from the list
15+
cd django-postgres # or the name of your project's working directory
16+
```
17+
18+
## Open the compose file
19+
20+
Let's take a quick look at the compose file. There are two services: `db` and `django`. Defang can generate a cost estimate of running the project described by this compose file in the cloud.
21+
22+
Notice that each service has a [`deploy.resources.reservations`](/docs/concepts/compose#deploy) property which describes the service's resource requirements. These numbers will have a significant impact on the cost of running these services in the cloud. The estimation defang generates for you will be sensitive to these numbers.
23+
24+
```yaml
25+
services:
26+
db:
27+
restart: unless-stopped
28+
image: postgres:16
29+
x-defang-postgres: true
30+
environment:
31+
- POSTGRES_DB=django
32+
- POSTGRES_USER=django
33+
- POSTGRES_PASSWORD
34+
ports:
35+
- mode: host
36+
target: 5432
37+
published: 5432
38+
healthcheck:
39+
test: ["CMD", "python3", "-c", "import sys, urllib.request; urllib.request.urlopen(sys.argv[1]).read()", "http://localhost:8000/"]
40+
deploy:
41+
resources:
42+
reservations:
43+
cpus: '0.5'
44+
memory: 256M
45+
46+
django:
47+
restart: unless-stopped
48+
build: ./app
49+
ports:
50+
- mode: ingress
51+
target: 8000
52+
published: 8000
53+
environment:
54+
- DB_HOST=db
55+
- DEBUG=False
56+
- POSTGRES_USER=django
57+
- POSTGRES_DB=django
58+
- POSTGRES_PASSWORD
59+
- SECRET_KEY
60+
- ALLOWED_HOSTS
61+
depends_on:
62+
- db
63+
deploy:
64+
resources:
65+
reservations:
66+
cpus: '0.5'
67+
memory: 256M
68+
```
69+
70+
## Generate an estimate
71+
72+
Generating an estimate is easy. All you need to do is run
73+
74+
```
75+
defang estimate
76+
```
77+
78+
Defang can deploy a project according to different [deployment modes](/docs/concepts/deployment-modes). By default, defang will estimate the cost deploying with the `affordable` mode. If you would like to increase your application's resiliency, you can deploy will the `balanced` or `high_availability` modes. Defang can estimate the cost of deploying using any of these modes.
79+
80+
```
81+
defang estimate --provider=gcp [--mode affordable|balanced|high_availability]
82+
```
83+
84+
Here is an example of the output you would see if you estimated the cost deploying the [django-postgres](https://github.com/DefangLabs/samples/tree/main/samples/django-postgres) sample using the `balanced` [deployment mode](/docs/concepts/deployment-modes).
85+
86+
```
87+
defang estimate --provider=gcp --mode=balanced
88+
* Packaging the project files for django at /Users/defang/samples/samples/django-postgres/app
89+
* Generating deployment preview
90+
* Preparing estimate
91+
92+
Estimate for Deployment Mode: BALANCED
93+
94+
This mode strikes a balance between cost and availability. Your application
95+
will be deployed with spot instances. Databases will be provisioned using
96+
resources optimized for production. Services in the "internal" network will
97+
be deployed to a private subnet with a NAT gateway for outbound internet access.
98+
99+
COST QUANTITY SERVICE DESCRIPTION
100+
$18.00 720 Hours (shared) Global Cloud Load Balancer Forwarding Rule (720 hours)
101+
$7.56 720 vCPU-Hours db CloudSQL for PostgreSQL (1 vCPU * 720 Hours)
102+
$18.00 720 Hours private-lb Cloud Load Balancer Forwarding Rule (720 hours)
103+
$0.00 0 GB-second django Cloud Run Active Time Memory ((first 360,000 GB-seconds free per month))
104+
$0.00 0 vCPU-second django Cloud Run Active Time vCPU ((first 180,000 vCPU-seconds free per month))
105+
$0.00 0 Requests django Cloud Run Requests ((first 2 million requests free per month))
106+
Estimated Monthly Cost: $43.56 (+ usage)
107+
108+
Estimate does not include taxes or Discount Programs.
109+
To estimate other modes, use defang estimate --mode=affordable|balanced|high_availability
110+
For help with warnings, check our FAQ at https://s.defang.io/warnings
111+
```
112+
113+
This estimate will include a line item for the most significant monthly costs associated with your deployment. Each line item will be associated with a compose service if possible. Some resources will be shared between multiple compose services.
114+
115+
:::note
116+
GCP Cloud Run is billed based on usage, so Cloud Run line items will show as $0.00 in the estimate.
117+
:::
118+
119+
## Deploying your project
120+
121+
Now that you have estimated the costs associated with your project. You are ready to deploy to GCP.
122+
123+
```
124+
defang compose up --provider gcp --mode affordable|balanced|high_availability
125+
```
126+

0 commit comments

Comments
 (0)