Skip to content

Commit ad968fa

Browse files
Merge pull request #2838 from madeline-underwood/review_django
Review django
2 parents 076d53a + 347802b commit ad968fa

11 files changed

Lines changed: 946 additions & 201 deletions

File tree

content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
---
2-
title: Deploy Django on Google Cloud C4A (Arm-based Axion VMs)
2+
title: Deploy Django on Arm-based Google Cloud C4A
33

4-
minutes_to_complete: 30
4+
minutes_to_complete: 60
55

6-
who_is_this_for: This Learning Path is for software developers deploying and optimizing Django-based web applications on Arm64 Linux environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
6+
who_is_this_for: This is an introductory topic for DevOps engineers and software developers who want to deploy, operate, and benchmark a production-grade Django REST API on Google Kubernetes Engine (GKE) running on Arm64 Axion processors, integrated with managed Google Cloud data services
77

88
learning_objectives:
9-
- Provision an Arm-based SUSE Linux Enterprise Server (SLES) virtual machine on Google Cloud (C4A with Axion processors)
10-
- Install Django on a SUSE Arm64 (C4A) instance
11-
- Verify Django functionality by running the development server and accessing the default welcome page on the Arm64 VM
12-
- Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (aarch64)
9+
- Provision Arm-based Axion compute on Google Cloud using virtual machines and GKE node pools
10+
- Package a Django REST API into an Arm-native Docker container
11+
- Push container images to Google Artifact Registry
12+
- Deploy Django on GKE using Kubernetes manifests (Deployment, Service, ConfigMap, Secrets)
13+
- Integrate Django with Cloud SQL (PostgreSQL) over private IP
14+
- Integrate Django with Memorystore (Redis) for caching and sessions
15+
- Expose Django using a Kubernetes LoadBalancer
16+
- Validate application connectivity to PostgreSQL and Redis
17+
- Measure throughput and p95 latency using ApacheBench against Gunicorn on Arm
1318

1419
prerequisites:
1520
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled
1621
- Basic familiarity with [Django](https://www.djangoproject.com/)
22+
- Basic understanding of containers and Kubernetes concepts
1723

1824
author: Pareena Verma
1925

@@ -27,9 +33,11 @@ armips:
2733

2834
tools_software_languages:
2935
- Django
30-
- Python
31-
- Gunicorn
32-
- Apache Bench
36+
- Docker
37+
- Kubernetes
38+
- Google Artifact Registry
39+
- Cloud SQL (PostgreSQL)
40+
- Memorystore (Redis)
3341

3442
operatingsystems:
3543
- Linux
@@ -47,13 +55,22 @@ further_reading:
4755
title: Django documentation
4856
link: https://docs.djangoproject.com/
4957
type: documentation
58+
- resource:
59+
title: Cloud SQL for PostgreSQL
60+
link: https://cloud.google.com/sql/docs/postgres
61+
type: documentation
62+
63+
- resource:
64+
title: Memorystore for Redis
65+
link: https://cloud.google.com/memorystore/docs/redis
66+
type: documentation
5067

5168
- resource:
52-
title: Apache-bench documentation
69+
title: Apache Bench documentation
5370
link: https://httpd.apache.org/docs/2.4/programs/ab.html
5471
type: documentation
5572

5673
weight: 1
5774
layout: "learningpathall"
58-
learning_path_main_page: "yes"
75+
learning_path_main_page: yes
5976
---

content/learning-paths/servers-and-cloud-computing/django-on-gcp/background.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Get started with Django on Google Axion C4A (Arm Neoverse-V2)
2+
title: Get started with Django on Google Axion C4A
33

44
weight: 2
55

@@ -12,10 +12,10 @@ Google Axion C4A is a family of Arm-based virtual machines built on Google’s c
1212

1313
The C4A series provides a cost-effective alternative to x86 virtual machines while leveraging the scalability and performance benefits of the Arm architecture in Google Cloud.
1414

15-
To learn more about Google Axion, see the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog.
15+
To learn more, see the Google blog [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu).
1616

1717

18-
## Understand Django on Google Axion C4A (Arm Neoverse-V2)
18+
## Explore Django on Google Axion C4A (Arm Neoverse V2)
1919

2020
Django is a high-level, open-source Python web framework that encourages rapid development and clean, pragmatic design. Developed and maintained by the [Django Software Foundation](https://www.djangoproject.com/foundation/), it simplifies web application development by handling much of the boilerplate and providing powerful built-in features.
2121

@@ -27,10 +27,13 @@ Common use cases include web applications, content management systems, APIs, e-c
2727

2828
To learn more, visit the [Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/).
2929

30-
## Summary and what's next
30+
## What you've accomplished and what's next
3131

32-
You now understand the capabilities of Google Axion C4A Arm-based VMs and why Django is an excellent choice for building web applications on Arm infrastructure. The combination provides a cost-effective, high-performance platform for deploying Python web applications at scale.
32+
In this section, you learned about:
33+
- Google Axion C4A Arm-based VMs and their performance characteristics
34+
- Django web framework and its suitability for building REST APIs
35+
- How Arm architecture provides cost-effective, high-performance infrastructure for Python applications
3336

34-
In the next sections, you'll provision your own Arm-based VM on Google Cloud, install Django, and benchmark your application's performance. You're ready to start building!
37+
Next, you'll configure firewall rules to allow external access to your Django application.
3538

3639

content/learning-paths/servers-and-cloud-computing/django-on-gcp/baseline.md

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,13 @@ weight: 6
66
layout: learningpathall
77
---
88

9-
## Verify Django is working on your Arm-based VM
9+
## Verify Django installation
1010

11-
In this section, you'll confirm that Django is installed correctly and can serve web requests on your Google Cloud C4A VM. You'll create a Django project, run the development server, and access it from your browser. This hands-on verification ensures your environment is ready for development and testing.
12-
13-
By the end of this section, you'll have:
14-
- Created a Django project with proper directory structure
15-
- Configured Django to accept requests from your VM's external IP
16-
- Run the development server and accessed it from your browser
17-
- Built a simple Django app with custom routing and views
18-
- Verified that Django can handle HTTP requests and render responses
19-
20-
Let's get started!
21-
22-
## Create and test a basic Django project
11+
In this section, you'll confirm that Django is installed correctly and can serve web requests on your Google Cloud C4A VM. You'll create a Django project, run the development server, and access it from your browser.
2312

2413
Run the following command to create a new Django project named `myproject`:
2514

26-
```console
15+
```bash
2716
django-admin startproject myproject
2817
cd myproject
2918
```
@@ -46,7 +35,7 @@ The `manage.py` file is Django's command-line utility for project management. Th
4635

4736
Set up your project's database by running migrations, which create the required tables for Django's built-in apps:
4837

49-
```console
38+
```bash
5039
python3 manage.py migrate
5140
```
5241

@@ -58,30 +47,29 @@ Before starting the Django development server, you must configure your `ALLOWED_
5847

5948
Navigate to your project settings directory:
6049

61-
```console
50+
```bash
6251
cd ~/myproject/myproject/
6352
```
6453

6554
Open `settings.py` using a text editor:
6655

67-
```console
68-
edit myproject/settings.py
69-
```
70-
71-
- Locate the `ALLOWED_HOSTS` Line
72-
Inside the file, find the following line:
56+
```bash
57+
edit myproject/settings.py
58+
```
59+
60+
Locate the `ALLOWED_HOSTS` line inside the file:
7361

7462
```python
7563
ALLOWED_HOSTS = []
7664
```
7765

7866
Update it to allow your VM's external IP address:
7967

80-
- Allow All Hosts (for Testing Only)
81-
To make your Django app accessible from your VM’s external IP address, update it to:
82-
```python
83-
ALLOWED_HOSTS = ['*']
84-
```
68+
To make your Django app accessible from your VM's external IP address, update it to:
69+
70+
```python
71+
ALLOWED_HOSTS = ['*']
72+
```
8573
{{% notice Note %}}
8674
For development and testing only, you can use `ALLOWED_HOSTS = ['*']` to allow all hosts. However, for production deployments, always specify explicit domain names or IP addresses such as `ALLOWED_HOSTS = ['your-external-ip', 'your-domain.com']`.
8775
{{% /notice %}}
@@ -92,7 +80,7 @@ ALLOWED_HOSTS = ['your-external-ip', 'your-domain.com']
9280

9381
Now that you've configured `ALLOWED_HOSTS`, start the development server:
9482

95-
```console
83+
```bash
9684
python3 manage.py runserver 0.0.0.0:8000
9785
```
9886

@@ -110,7 +98,7 @@ Replace `<YOUR_VM_EXTERNAL_IP>` with the public IP address of your GCP VM.
11098

11199
You should see the Django welcome page with the message "The install worked successfully!":
112100

113-
![Screenshot of the Django welcome page displayed in a web browser. The page features a large heading stating The install worked successfully followed by a subheading congratulating the user on successfully installing Django. Below are instructions for the next steps, including editing the settings file and reading the Django documentation. The page has a clean white background with blue highlights. alt-text#center](images/django-welcome-page.png "Django welcome page")
101+
![Screenshot of the Django welcome page displayed in a web browser. The page features a large heading stating The install worked successfully followed by a subheading congratulating the user on successfully installing Django. Below are instructions for the next steps, including editing the settings file and reading the Django documentation. The page has a clean white background with blue highlights alt-txt#center](images/django-welcome-page.png "Django welcome page")
114102

115103
## Build a simple Django app with custom routing
116104

@@ -124,7 +112,7 @@ Press **Ctrl + C** in your terminal to stop the Django development server.
124112

125113
Within your Django project directory, create a new app named `hello`:
126114

127-
```console
115+
```bash
128116
python3 manage.py startapp hello
129117
```
130118

@@ -148,7 +136,7 @@ Edit `hello/views.py` and replace the entire file with:
148136
from django.http import HttpResponse
149137

150138
def home(request):
151-
return HttpResponse("<h1>Hello, Django on Arm!</h1>")
139+
return HttpResponse("<h1>Hello, Django on GCP SUSE ARM64!</h1>")
152140
```
153141

154142
This simple view function returns a basic HTML message as an HTTP response.
@@ -220,7 +208,7 @@ INSTALLED_APPS = [
220208

221209
Restart the Django development server:
222210

223-
```console
211+
```bash
224212
python3 manage.py runserver 0.0.0.0:8000
225213
```
226214

@@ -232,10 +220,15 @@ Open your browser and navigate to:
232220
http://<YOUR_VM_EXTERNAL_IP>:8000
233221
```
234222

235-
You should now see your custom message displayed:
223+
Your browser displays your custom message:
224+
225+
![Screenshot of a web browser displaying a Django app with a large heading that reads Hello, Django on Arm, centered on a clean white background alt-txt#center](images/django-app.png "Django custom app")
236226

237-
![Screenshot of a web browser displaying a Django app with a large heading that reads Hello, Django on Arm centered on a clean white background. The page contains no additional content or navigation, creating a straightforward and welcoming tone. alt-text#center](images/django-app.png "Django custom app")
227+
## What you've accomplished and what's next
238228

239-
## Summary and what's next
229+
In this section, you:
230+
- Created a Django project and ran the development server
231+
- Built a custom Django app with routing and views
232+
- Verified that Django serves web requests successfully on your Arm VM
240233

241-
You've successfully verified that Django is installed and working on your Arm-based VM. Your application can serve web requests, handle routing, and render custom views. Great job, you're ready to benchmark your Django application!
234+
Next, you'll set up the complete GKE infrastructure with Cloud SQL and Memorystore for production deployment.

0 commit comments

Comments
 (0)