diff --git a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md index 4c1ce1bcd8..ff1cf3601e 100644 --- a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md +++ b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/_index.md @@ -1,19 +1,15 @@ --- title: Deploy Django on Google Cloud C4A (Arm-based Axion VMs) - -draft: true -cascade: - draft: true minutes_to_complete: 30 -who_is_this_for: This learning path is intended for software developers deploying and optimizing Django-based web applications on Linux/Arm64 environments, specifically using Google Cloud C4A virtual machines powered by Axion processors. +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. learning_objectives: - - Provision an Arm-based SUSE SLES virtual machine on Google Cloud (C4A with Axion processors) + - Provision an Arm-based SUSE Linux Enterprise Server (SLES) virtual machine on Google Cloud (C4A with Axion processors) - Install Django on a SUSE Arm64 (C4A) instance - Verify Django functionality by running the development server and accessing the default welcome page on the Arm64 VM - - Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (Aarch64) + - Measure Django application performance by benchmarking request handling throughput and latency using the official ApacheBench (ab) tool with Gunicorn on Arm64 (aarch64) prerequisites: - A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled diff --git a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/background.md b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/background.md index 8b2a674186..53ff45dda6 100644 --- a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/background.md +++ b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/background.md @@ -1,27 +1,36 @@ --- -title: Getting started with Django on Google Axion C4A (Arm Neoverse-V2) +title: Get started with Django on Google Axion C4A (Arm Neoverse-V2) weight: 2 layout: "learningpathall" --- -## Google Axion C4A Arm instances in Google Cloud +## Explore Axion C4A Arm instances in Google Cloud Google Axion C4A is a family of Arm-based virtual machines built on Google’s custom Axion CPU, which is based on Arm Neoverse-V2 cores. Designed for high-performance and energy-efficient computing, these virtual machines offer strong performance for modern cloud workloads such as CI/CD pipelines, microservices, media processing, and general-purpose applications. 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. -To learn more about Google Axion, refer to the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog. +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. -## Django -[Django](https://www.djangoproject.com/) 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. +## Understand Django on Google Axion C4A (Arm Neoverse-V2) -Django follows the **Model–View–Template (MVT)** architectural pattern and includes robust tools for **authentication**, **URL routing**, **form handling**, **ORM (Object Relational Mapping)**, **session management**, and **administration interface** — all out of the box. +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. -Django is known for its focus on **security**, **scalability**, and **maintainability**, making it suitable for everything from small projects to large-scale enterprise applications. It helps developers build secure, high-performance web applications quickly without reinventing common components. +Django follows the Model–View–Template (MVT) architectural pattern and includes robust tools for authentication, URL routing, form handling, ORM (Object Relational Mapping), session management, and administration interface - all out of the box. + +Django is known for its focus on security, scalability, and maintainability, making it suitable for everything from small projects to large-scale enterprise applications. It helps developers build secure, high-performance web applications quickly without reinventing common components. + +Common use cases include web applications, content management systems, APIs, e-commerce platforms, and data-driven dashboards. It integrates seamlessly with popular databases like PostgreSQL, MySQL, SQLite, and Oracle. + +To learn more, visit the [Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/). + +## Summary and what's next + +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. + +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! -Common use cases include **web applications**, **content management systems**, **APIs**, **e-commerce platforms**, and **data-driven dashboards**. It integrates seamlessly with popular databases like **PostgreSQL**, **MySQL**, **SQLite**, and **Oracle**. -To learn more, visit the [official Django website](https://www.djangoproject.com/) and explore the [Django documentation](https://docs.djangoproject.com/en/stable/). diff --git a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/baseline.md b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/baseline.md index 955ce42de5..15eca68372 100644 --- a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/baseline.md +++ b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/baseline.md @@ -1,19 +1,26 @@ --- -title: Django Baseline Testing on Google Axion C4A Arm Virtual Machine +title: Verify Django installation and run the development server weight: 6 ### FIXED, DO NOT MODIFY layout: learningpathall --- -## Django Baseline Testing on GCP SUSE VMs -This baseline testing guide verifies that your **Django installation**, **web server**, and **basic application routing** are functioning correctly on a **Google Cloud SUSE Linux Arm64 (Axion C4A)** virtual machine. -You will first run the Django development server and access it from your browser, then create a simple Django app to ensure routing works. +## Verify Django is working on your Arm-based VM -### Baseline 1 — View Django Welcome Page -This test confirms that Django is installed correctly and the server runs successfully. +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. + +By the end of this section, you'll have: +- Created a Django project with proper directory structure +- Configured Django to accept requests from your VM's external IP +- Run the development server and accessed it from your browser +- Built a simple Django app with custom routing and views +- Verified that Django can handle HTTP requests and render responses + +Let's get started! + +## Create and test a basic Django project -#### Create a new Django project Run the following command to create a new Django project named `myproject`: ```console @@ -32,33 +39,30 @@ myproject/ ├── asgi.py └── wsgi.py ``` -- `manage.py` is Django’s command-line utility for project management (running server, migrations, etc.). -- The inner `myproject/` folder contains the core configuration files that define your project’s settings and URLs.- -#### Run initial migrations -Migrations prepare your project’s database by creating the required tables for Django’s internal apps (admin, authentication, etc.): +The `manage.py` file is Django's command-line utility for project management. The inner `myproject/` folder contains your project's core settings and URL configuration. + +## Run initial database migrations + +Set up your project's database by running migrations, which create the required tables for Django's built-in apps: ```console python3 manage.py migrate ``` -You should get output showing the Running Migrations (all of which should be "OK"). +The output shows all migrations applied successfully (marked "OK"). -#### Start the Django development server -Before starting the Django development server, you must configure your ALLOWED_HOSTS setting to allow access from your VM’s external IP. -This ensures that Django accepts HTTP requests from outside the localhost (e.g., when testing in a browser or from another machine). +## Configure ALLOWED_HOSTS for external access -**ALLOWED_HOSTS:** is a security setting in Django that defines which host/domain names your Django site can serve. +Before starting the Django development server, you must configure your `ALLOWED_HOSTS` setting to allow access from your VM's external IP. This ensures that Django accepts HTTP requests from outside localhost (for example, when testing in a browser from another machine). -- Navigate to Your Project Settings - Move into your Django project directory where the settings.py file is located. +Navigate to your project settings directory: - ```console - cd ~/myproject/myproject/ - ``` +```console +cd ~/myproject/myproject/ +``` -- Open settings.py File - Use any text editor (like vi or nano) to open the file ("edit" is used as an example below). +Open `settings.py` using a text editor: ```console edit myproject/settings.py @@ -67,10 +71,11 @@ This ensures that Django accepts HTTP requests from outside the localhost (e.g., - Locate the `ALLOWED_HOSTS` Line Inside the file, find the following line: - ```python - ALLOWED_HOSTS = [] - ``` - This setting defines which host/domain names Django will serve. +```python +ALLOWED_HOSTS = [] +``` + +Update it to allow your VM's external IP address: - Allow All Hosts (for Testing Only) To make your Django app accessible from your VM’s external IP address, update it to: @@ -78,49 +83,54 @@ This ensures that Django accepts HTTP requests from outside the localhost (e.g., ALLOWED_HOSTS = ['*'] ``` {{% notice Note %}} -Allowing all hosts `('*')` is suitable **only for development or testing**. -For production, replace `'*'` with specific domain names or IPs, such as your public IP address for your VM that you recorded earlier: +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']`. {{% /notice %}} ```python ALLOWED_HOSTS = ['your-external-ip', 'your-domain.com'] ``` -**Now start the Django development server:** +Now that you've configured `ALLOWED_HOSTS`, start the development server: -We can now start the Django development server since we have exposed TCP/8000 in our VM via firewall rules: ```console python3 manage.py runserver 0.0.0.0:8000 ``` -#### View in browser -Open a web browser on your local machine (Chrome, Firefox, Edge, etc.) and enter the following URL in the address bar. Please replace "YOUR_VM_EXTERNAL_IP" with the external IP address of your VM that you saved off earlier: +This starts the Django development server on port 8000, listening on all network interfaces. -```console +## Access Django in your browser + +Open a web browser on your local machine and navigate to: + +``` http://:8000 ``` -- Replace `` with the public IP of your GCP VM. -If everything is set up correctly, you should see the default Django welcome page (“The install worked successfully!”). It looks like this: +Replace `` with the public IP address of your GCP VM. + +You should see the Django welcome page with the message "The install worked successfully!": + +![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") -![Django welcome page alt-text#center](images/django-welcome-page.png "Figure 1: Django web page") +## Build a simple Django app with custom routing -### Baseline 2 — Create a Simple Django App -This test ensures Django’s application routing and view rendering work as expected. +This section demonstrates that Django's application routing and view rendering work correctly by creating a simple app with a custom view. -#### Stop the server -Press `Ctrl + C` to stop the Django server if running. +## Stop the server + +Press **Ctrl + C** in your terminal to stop the Django development server. + +## Create a new Django app -#### Create a new app Within your Django project directory, create a new app named `hello`: ```console python3 manage.py startapp hello ``` -**This creates the following directory:** +This generates the following directory structure with files for views, models, configuration, and more: -```markdown +```output hello/ ├── admin.py ├── apps.py @@ -130,19 +140,22 @@ hello/ └── urls.py ``` -#### Create a simple view -Edit `hello/views.py`. Replace your existing file with this: +## Define a view function + +Edit `hello/views.py` and replace the entire file with: ```python from django.http import HttpResponse def home(request): - return HttpResponse("

Hello, Django on GCP SUSE ARM64!

") + return HttpResponse("

Hello, Django on Arm!

") ``` -This defines a simple view function that sends a basic HTML message as the HTTP response. -#### Create app URL configuration -Create a new file `hello/urls.py` and add: +This simple view function returns a basic HTML message as an HTTP response. + +## Create URL configuration for your app + +Create a new file `hello/urls.py`: ```python from django.urls import path @@ -152,10 +165,12 @@ urlpatterns = [ path('', views.home, name='home'), ] ``` -This maps the root URL `(/)`of your app to the `home()` view function. -#### Link the app to the main project -Replace your default `myproject/urls.py` file with this version. +This maps the root URL path to your `home()` view function. + +## Include the app in your project's main URLs + +Edit `myproject/urls.py` to include the `hello` app's URLs: ```python """myproject URL Configuration @@ -182,11 +197,12 @@ urlpatterns = [ path('', include('hello.urls')), ] ``` -This tells Django to delegate routing for the root path (`''`) to the `hello` app’s URLs. -#### Add the app to settings -This makes Django aware of your new app so it can load its configuration and routes. -Edit `myproject/settings.py` → add `'hello'` to INSTALLED_APPS: +This tells Django to route the root path to your `hello` app. + +## Register the app in Django settings + +Django needs to know about your new app. Edit `myproject/settings.py` and add `'hello'` to the `INSTALLED_APPS` list: ```python INSTALLED_APPS = [ @@ -199,18 +215,27 @@ INSTALLED_APPS = [ 'hello', ] ``` -#### Run the server again + +## Start the server again + +Restart the Django development server: ```console python3 manage.py runserver 0.0.0.0:8000 ``` -#### Test your app -Open in browser: +## Test your custom app + +Open your browser and navigate to: -```console -http://:8000 ``` -You should see the Django app. It looks like this: +http://:8000 +``` + +You should now see your custom message displayed: + +![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") + +## Summary and what's next -![Django App alt-text#center](images/django-app.png "Figure 2: Django App") +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! diff --git a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/benchmarking.md b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/benchmarking.md index 230ecad863..fe5dcd7063 100644 --- a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/benchmarking.md +++ b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/benchmarking.md @@ -1,71 +1,74 @@ --- -title: Django Benchmarking +title: Benchmark Django application performance on Arm weight: 7 ### FIXED, DO NOT MODIFY layout: learningpathall --- +## Benchmark your Django application with ApacheBench and Gunicorn -## Django Benchmarking using ApacheBench -This section describes how to benchmark a Django web application deployed with **Gunicorn** using **ApacheBench (ab)** — a lightweight HTTP benchmarking tool. -You will measure **throughput (requests per second)** and **latency (response time)** to evaluate the performance of your Django app on an Arm-based GCP SUSE VM. +This section guides you through benchmarking your Django web application using Gunicorn as a production-like WSGI server and ApacheBench (`ab`) for load testing. You'll measure throughput (requests per second) and latency (response time) to evaluate your Django app's performance on an Arm-based Google Cloud C4A VM. -### Stop the server -Press `Ctrl + C` to stop the Django server if running. +## Install ApacheBench -### Ensure ApacheBench is installed -**ApacheBench (ab)** is a command-line tool used to benchmark web servers by simulating multiple HTTP requests. +To begin, if your Django development server is still running, stop it using `Ctrl + C`. -Install it using following command: +ApacheBench (`ab`) is a command-line tool that simulates multiple HTTP requests to measure web server performance. Install it using the following: ```console sudo zypper install -y apache2-utils ``` -**Verify installation:** +## Verify installation -This confirms ApacheBench is correctly installed and available system-wide. +This command confirms ApacheBench is correctly installed and available system-wide: ```console ab -V ``` -**Ensure Django and Gunicorn are installed:** +The output displays the ApacheBench version, confirming successful installation. + +## Install and configure Gunicorn + +Before benchmarking your Django application, you need to install Gunicorn, a production-grade WSGI HTTP server. Gunicorn provides better performance characteristics than Django's development server and more accurately represents real-world deployment scenarios. + +Install both Django and Gunicorn using pip: ```console python3 -m pip install django gunicorn ``` -- **Django** is the Python web framework you’re benchmarking. -- **Gunicorn** is a high-performance WSGI HTTP server for deploying Django apps in production-like environments. -### Run Django with Gunicorn -Use Gunicorn to serve your Django application for benchmarking (run in the background): +This command installs two essential packages. Django is the Python web framework you're benchmarking, while Gunicorn serves as a high-performance WSGI HTTP server that handles multiple concurrent requests efficiently. Unlike Django's built-in development server, Gunicorn is designed for production workloads and provides the multi-worker architecture needed for accurate performance testing. + + +## Run Django with Gunicorn + +Start your Django application using Gunicorn: ```console gunicorn myproject.wsgi:application --bind 0.0.0.0:8000 --workers 4 & ``` -- `--workers 4`: number of worker processes -- `--bind 0.0.0.0:8000`: binds to all interfaces on port 8000 -- `myproject.wsgi:application` your Django project name ("myproject" used in this example). +This command starts Gunicorn with four worker processes to handle concurrent requests. Replace `myproject` with your Django project's actual name. The `--bind 0.0.0.0:8000` flag makes the server accessible on port 8000 from any network interface, while the `&` runs the process in the background so you can continue using your terminal. {{% notice Note %}} -Keep this terminal running during the benchmark. If you’re testing remotely, ensure port 8000 is open in your VM firewall settings. +Ensure your VM's firewall allows inbound traffic on port 8000. See the firewall setup section if you haven't already configured this. {{% /notice %}} -### Benchmark with ApacheBench (ab) -Run ApacheBench to simulate multiple clients hitting your Django server. +## Run the benchmark +Use ApacheBench to test your Django server with simulated traffic: ```console ab -n 1000 -c 10 http://127.0.0.1:8000/ ``` -- `-n 1000`: total number of requests -- `-c 10`: concurrency (simultaneous requests) -You should see an output similar to: +This sends 1000 requests using 10 concurrent connections to your local server's root URL. The `-n` flag sets the total number of requests, while `-c` controls how many run simultaneously. + +The output is similar to: ```output -This is ApacheBench, Version 2.3 <$Revision: 1903618 $> +This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ @@ -82,7 +85,6 @@ Completed 900 requests Completed 1000 requests Finished 1000 requests - Server Software: gunicorn Server Hostname: 127.0.0.1 Server Port: 8000 @@ -119,25 +121,43 @@ Percentage of the requests served within a certain time (ms) 99% 3 100% 5 (longest request) ``` +## Stop the Gunicorn server -### Cleanup +After reviewing the benchmark results, stop the Gunicorn server running in the background: -With the following output (above) seen, you can type "fg" followed by "ctrl-c" to exit the gunicorn server that is running. +```bash +fg +``` -### Benchmark Metrics Explanation +This brings the background Gunicorn process to the foreground. Then press `Ctrl+C` to stop it. -- **Concurrency Level:** Number of requests executed simultaneously during the test. -- **Time Taken for Tests:** Total time required to complete all HTTP requests. -- **Complete Requests:** Total number of successful requests processed. -- **Failed Requests:** Number of requests that failed or returned errors. -- **Total Transferred:** Total amount of data (including headers) sent and received. -- **HTML Transferred:** Amount of actual response content transferred. -- **Requests per Second:** Average number of requests handled by the server per second. -- **Time per Request (mean):** Average time taken to process a single request. -- **Time per Request (across concurrent):** Mean time per request across all concurrent clients. -- **Transfer Rate:** Average network data throughput during the benchmark. +## Interpret your benchmark results + +The ApacheBench output provides key performance metrics that help you evaluate your Django application's capabilities on Arm. Here's what each metric tells you: +### Request handling metrics +- Concurrency Level: number of simultaneous requests the benchmark sent (10 in this example) +- Complete Requests: total successful requests processed (1000 in this test) +- Failed Requests: number of errors or timeouts (0 indicates stable performance) + +### Performance metrics +- Requests per Second: how many requests your server handles per second - higher values indicate better throughput +- Time per Request (mean): average time to complete a single request - lower values mean faster responses +- Time per Request (across concurrent): average latency when factoring in concurrent processing, this shows how well your app handles parallel requests + +### Data transfer metrics +- Total Transferred: all data sent and received, including HTTP headers +- HTML Transferred: actual response content size +- Transfer Rate: network throughput in KB/sec—indicates data handling efficiency +### Timing breakdown +- Time Taken for Tests: total benchmark duration +- Connection Times: shows minimum, mean, median, and maximum times for connecting, processing, and waiting + +These metrics provide a performance baseline for your Django application on Arm. You can use them to compare different configurations, identify bottlenecks, or validate optimizations. + +## Benchmark summary + +The table below summarizes the key performance indicators from the benchmark test. These results demonstrate the capabilities of your Django application running on a Google Cloud C4A Arm-based VM with Gunicorn. -### Benchmark summary Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE): | **Parameter** | **Description** | **Value** | @@ -158,8 +178,12 @@ Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm6 | **Time per Request (across all concurrent requests)** | Average latency considering concurrency | **0.104 ms** | | **Transfer Rate** | Network throughput rate | **2639.00 KB/sec** | -- **Exceptional Throughput:** The Arm64 VM efficiently handled nearly 10K requests per second, showcasing excellent concurrency handling. -- **Low Latency:** Average response time stayed around 1 ms, indicating rapid request processing even under load. -- **High Efficiency:** Zero failed requests demonstrate stable and reliable performance under benchmark conditions. -- **Optimized Networking:** Strong data transfer rate highlights Arm64’s efficient network I/O capabilities. -- **Ideal for Scalable Apps:** The consistent and predictable response times make Arm64 VMs well-suited for high-performance web workloads. +## Key performance insights + +The benchmark results reveal several important characteristics of running Django on Arm-based infrastructure: + +- Exceptional Throughput: the Arm64 VM efficiently handled nearly 10K requests per second, showcasing excellent concurrency handling. +- Low Latency: average response time stayed around 1 ms, indicating rapid request processing even under load. +- High Efficiency: zero failed requests demonstrate stable and reliable performance under benchmark conditions. +- Optimized Networking: strong data transfer rate highlights Arm64's efficient network I/O capabilities. +- Ideal for Scalable Apps: the consistent and predictable response times make Arm64 VMs well-suited for high-performance web workloads. diff --git a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/firewall_setup.md b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/firewall_setup.md index 983fcdb15c..771c5d63d8 100644 --- a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/firewall_setup.md +++ b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/firewall_setup.md @@ -1,42 +1,55 @@ --- -title: Create a Firewall Rule on GCP +title: Configure firewall rules for Django on Google Cloud weight: 3 ### FIXED, DO NOT MODIFY layout: learningpathall --- -## Overview +## Open port 8000 for your Django application -In this section, you will learn how to create a Firewall Rule within Google Cloud Console. For this learning path, we need to expose TCP port 8000. +Before you can access your Django development server from your browser, you need to configure Google Cloud's firewall to allow inbound traffic on port 8000. This section walks you through creating a firewall rule that permits HTTP requests to reach your VM. {{% notice Note %}} For support on GCP setup, see the Learning Path [Getting started with Google Cloud Platform](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/google/). {{% /notice %}} -## Create a Firewall Rule in GCP -For this learning path, we need to expose TCP port 8000. To accomplish this, we first need to create a firewall rule. -- Navigate to the [Google Cloud Console](https://console.cloud.google.com/). -- Go to **VPC Network > Firewall** and press **Create firewall rule**. +## Create a firewall rule in Google Cloud Console -![Create a firewall rule](images/firewall-rule.png "Create a firewall rule") +Navigate to the Google Cloud Console and create a new firewall rule: -- Next, we create the firewall rule that will expose TCP port 8000 for our learning path. -- Set the "Name" of the new rule to "allow-tcp-8000" -- Select your network that you intend to bind to your VM (default is "autoscaling-net" but your organization might have others that you need to use) -- Direction of traffic should be set to "Ingress" -- Allow on match should be set to "Allow" and the "Targets" should be set to "Specified target tags". -- Enter "allow-tcp-8000" to the "Target tags" text field -- Set the "Source IPv4 ranges" text value to "0.0.0.0/0" +- Go to the **Google Cloud Console** +- Select **VPC network** > **Firewall** +- Select **Create firewall rule** -![Create a firewall rule](images/network-rule.png "Creating the TCP/8000 firewall rule") +![Screenshot of the Google Cloud Console showing the Firewall section. The Create firewall rule button is prominently displayed at the top of the page. alt-text#center](images/firewall-rule.png "Google Cloud Console Firewall page") -- Lastly, we select "Specified protocols and ports" under the "Protocols and ports" section -- Select the "TCP" checkbox -- Enter "8000" in the "Ports" text field -- Press "Create" +## Configure the firewall rule -![Specifying the TCP port to expose](images/network-port.png "Specifying the TCP port to expose") +Fill in the rule details to allow traffic on port 8000: -Our network firewall rule is now created so we can continue with the VM creation! \ No newline at end of file +- Set **Name** to `allow-django-8000`. +- Select your network (the default is `default`; your organization may use a different network). +- Set **Direction of traffic** to **Ingress**. +- Set **Action on match** to **Allow**. +- Set **Targets** to **Specified target tags**. +- Enter `django-server` in the **Target tags** field. +- Set **Source IPv4 ranges** to `0.0.0.0/0` (allows traffic from any IP address; restrict this in production). + +![Screenshot showing the firewall rule configuration form. The Name field shows allow-django-8000, Direction is set to Ingress, and Targets is set to Specified target tags. alt-text#center](images/network-rule.png "Firewall rule configuration") + +## Specify the port and protocol + +Configure the protocol and port settings: + +- Under **Protocols and ports**, select **Specified protocols and ports**. +- Check the **TCP** checkbox. +- Enter `8000` in the **Ports** field. +- Click **Create**. + +![Screenshot of the Protocols and ports section. The TCP checkbox is checked and port 8000 is entered in the Ports field. alt-text#center](images/network-port.png "Specifying TCP port 8000") + +## Summary and what's next + +Your firewall rule is now created and active. Your Django application running on port 8000 is now accessible from external IP addresses. You're ready to proceed with VM creation and Django installation! \ No newline at end of file diff --git a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/installation.md b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/installation.md index 1271b33f9b..ac3bb5cb0c 100644 --- a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/installation.md +++ b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/installation.md @@ -1,71 +1,90 @@ --- -title: Install Django +title: Install Django on your Arm-based VM weight: 5 ### FIXED, DO NOT MODIFY layout: learningpathall --- -## Install Django on GCP VM -This guide walks you through installing Django on a **Google Cloud Platform (GCP) SUSE Linux Arm64 VM**, including all dependencies, Python setup, and environment preparation. +## Install Django and dependencies -### Update Your System -Before installing Django, it’s good practice to update your package list and upgrade installed software to ensure you have the latest versions and security patches. +After connecting to your SUSE Linux Enterprise Server (SLES) VM using SSH, you'll update your system, install Python 3.11, and set up a virtual environment for your Django project. + +## Update your system + +Begin by refreshing your package list and upgrading installed software to ensure you have the latest versions and security patches: ```console sudo zypper refresh sudo zypper update -y ``` -### Install Python and Tools -**Django** requires **Python 3.10+**. We will use Python 3.11, which is compatible with Django 5. -You will also install `pip` for package management, and basic developer tools (`git`, `gcc`, and `make`) to build Python packages and work with Django projects. +## Install Python 3.11 and development tools + +Django requires Python 3.10 or later. You'll install Python 3.11 along with pip (Python's package manager) and essential build tools needed for compiling Python packages: + ```console -sudo zypper install -y python311 python311-pip python311-devel -sudo zypper install -y git gcc make +sudo zypper install -y python311 python311-pip python311-devel git gcc make ``` -**Ensure that both Python and pip are installed correctly:** +Verify that Python and pip are installed correctly: -```console +```bash python3.11 --version -pip3 --version +pip3.11 --version ``` -You should see an output similar to: +The output is similar to: + ```output Python 3.11.10 pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11) ``` -### Create a Project Folder and Virtual Environment -It’s recommended to create a dedicated project directory and use a **virtual environment** to isolate project dependencies. +## Create a project directory and virtual environment + +Create a dedicated directory for your Django project and set up a Python virtual environment to isolate your project's dependencies: ```console mkdir ~/myproject && cd ~/myproject python3.11 -m venv venv source venv/bin/activate ``` -- `python3.11 -m venv venv` — creates a virtual environment named venv inside your project folder. -- `source venv/bin/activate` — activates the virtual environment. -Once activated, your command prompt will show (venv) at the beginning, indicating that you’re working inside an isolated Python environment. -### Upgrade Pip and Install Django -With your virtual environment active, upgrade pip and install Django using the following commands: +The `python3.11 -m venv venv` command creates an isolated Python environment named `venv` inside your project folder. Running `source venv/bin/activate` activates this environment. + +Once activated, your command prompt displays `(venv)` at the beginning, indicating you're working inside an isolated Python environment where all packages are isolated from your system Python installation. + +## Upgrade pip and install Django + +With your virtual environment active, upgrade pip to the latest version: ```console python3 -m pip install --upgrade pip -python3 -m pip install django ``` -**Confirm that Django is installed correctly by checking its version:** +Now install Django and additional useful packages for web development: -```console +```bash +python3 -m pip install django gunicorn +``` + +This installs: +- **Django** — the web framework for building your application +- **Gunicorn** — a production-ready WSGI (Web Server Gateway Interface) server for running Django applications + +Verify that Django is installed correctly: + +```bash django-admin --version ``` -You should see an output similar to: +The output is similar to: + ```output 5.2.8 ``` -Django is installed successfully and ready for project setup. + +## Summary and what's next + +You have successfully installed Django and all required dependencies on your Arm-based VM. Your environment is now ready for creating Django projects and applications! diff --git a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/instance.md b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/instance.md index e708afde53..4a06fbe1fc 100644 --- a/content/learning-paths/servers-and-cloud-computing/django-on-gcp/instance.md +++ b/content/learning-paths/servers-and-cloud-computing/django-on-gcp/instance.md @@ -6,12 +6,12 @@ weight: 4 layout: learningpathall --- -## Overview +## Provision a Google Axion C4A Arm VM -In this section, you will learn how to provision a Google Axion C4A Arm virtual machine on Google Cloud Platform (GCP) using the `c4a-standard-4` (4 vCPUs, 16 GB memory) machine type in the Google Cloud Console. +You'll create a Google Axion C4A Arm-based virtual machine (VM) on Google Cloud Platform (GCP) using the `c4a-standard-4` machine type (4 vCPUs, 16 GB memory). This VM will host your Django application. {{% notice Note %}} -For support on GCP setup, see the Learning Path [Getting started with Google Cloud Platform](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/google/). +For help with GCP setup, see the Learning Path [Getting started with Google Cloud Platform](/learning-paths/servers-and-cloud-computing/csp/google/). {{% /notice %}} ## Provision a Google Axion C4A Arm VM in Google Cloud Console @@ -24,7 +24,7 @@ To create a virtual machine based on the C4A instance type: - Set **Series** to `C4A`. - Select `c4a-standard-4` for machine type. - ![Create a Google Axion C4A Arm virtual machine in the Google Cloud Console with c4a-standard-4 selected alt-text#center](images/gcp-vm.png "Creating a Google Axion C4A Arm virtual machine in Google Cloud Console") +![Screenshot of the Google Cloud Console showing the Machine configuration section. The Series dropdown is set to C4A and the machine type c4a-standard-4 is selected. alt-text#center](images/gcp-vm.png "Configuring machine type to C4A in Google Cloud Console") - Under **OS and Storage**, select **Change**, then choose an Arm64-based OS image. For this Learning Path, use **SUSE Linux Enterprise Server**. @@ -33,17 +33,23 @@ To create a virtual machine based on the C4A instance type: - Under **Networking**, enable **Allow HTTP traffic**. - Also under **Networking**, in the "Network tags" text field add "allow-tcp-8000" as an additional tag -![Adding the TCP/8000 firewall rule to our VM](images/network-config.png "Adding the TCP/8000 firewall rule to our VM") +![Screenshot showing the Networking configuration section. The Allow HTTP traffic checkbox is enabled and the Network tags field contains django-server. alt-text#center](images/network-config.png "Configuring networking and tags") -- Click **Create** to launch the instance. -- Once created, you should see a "SSH" option to the right in your list of VM instances. You should also see the public IP address for your VM. -- Save off the public IP address for your VM as you will need this in the next step. -- Click on this to launch a SSH shell into your VM instance: +## Create the instance -![Invoke a SSH session via your browser alt-text#center](images/gcp-pubip-ssh.png "Invoke a SSH session into your running VM instance") +Click **Create** to launch your VM instance. Google Cloud provisions the instance, which typically takes one to two minutes. +Once the instance is running, you'll see it listed in the VM instances table with a green checkmark. Note the External IP address displayed in the list—you'll need this to access your Django application later. -- A window from your browser should come up and you should now see a shell into your VM instance: +## Connect using SSH -![Terminal Shell in your VM instance alt-text#center](images/gcp-shell.png "Terminal shell in your VM instance") +Click the **SSH** button next to your running instance to open a browser-based terminal session. -Next, let's install django! \ No newline at end of file +![Screenshot of the VM instances list showing the SSH button next to a running instance. The external IP address is visible in the same row. alt-text#center](images/gcp-pubip-ssh.png "Launching an SSH session from the VM instances list") + +A browser window opens with a terminal shell connected to your VM. You're now ready to install Django. + +![Screenshot of a terminal shell in the browser, connected to the running VM instance. The shell displays a command prompt ready for input. alt-text#center](images/gcp-shell.png "Terminal shell connected to your VM") + +## Summary and what's next + +You have successfully provisioned an Arm-based VM on Google Cloud. Next, you'll install Django and configure your web application! \ No newline at end of file