Skip to content

Commit f28f5c9

Browse files
initial changes to django TR
1 parent 4889cde commit f28f5c9

5 files changed

Lines changed: 167 additions & 72 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Edit `hello/views.py` and replace the entire file with:
148148
from django.http import HttpResponse
149149

150150
def home(request):
151-
return HttpResponse("<h1>Hello, Django on Arm!</h1>")
151+
return HttpResponse("<h1>Hello, Django on GCP SUSE ARM64!</h1>")
152152
```
153153

154154
This simple view function returns a basic HTML message as an HTTP response.

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ This step sets up a clean Python virtual environment and installs all runtime de
1717
mkdir ~/django_api && cd ~/django_api
1818
python3 -m venv venv
1919
source venv/bin/activate
20-
pip install django djangorestframework psycopg2-binary django-redis gunicorn
20+
sudo zypper install postgresql-devel libpq5 postgresql15-server-devel gcc make python3-devel
21+
which pg_config
22+
pip install psycopg2-binary django djangorestframework psycopg2-binary django-redis gunicorn
2123
```
2224

2325
```console
@@ -28,7 +30,7 @@ You now have a Django project skeleton with all required libraries installed for
2830

2931
### Enable Django Apps
3032
Django must be told which components are active. We enable the REST framework and the API app so that Django can expose HTTP endpoints.
31-
Edit `django_api/settings.py`
33+
Edit `django_api/settings.py` and add 'rest_framework' and 'api' to INSTALLED_APPS. Set DEBUG to False. Finally add '*' to ALLOWED_HOSTS.
3234

3335
```python
3436
INSTALLED_APPS = [
@@ -52,6 +54,8 @@ Your Django project is now configured to run as an API server instead of a devel
5254

5355
This step connects Django to external managed services instead of local SQLite. This mirrors how real production systems operate.
5456

57+
Edit `django_api/settings.py` and replace the DATABASES configuration with this:
58+
5559
```python
5660
DATABASES = {
5761
'default': {
@@ -63,14 +67,19 @@ DATABASES = {
6367
'PORT': '5432',
6468
}
6569
}
70+
```
71+
72+
Additionally, add the CACHES configuration per below to the same file and save:
6673

74+
```python
6775
CACHES = {
6876
"default": {
6977
"BACKEND": "django_redis.cache.RedisCache",
7078
"LOCATION": "redis://REDIS_IP:6379/1",
7179
}
7280
}
7381
```
82+
7483
Your application is now wired to a real database and cache, making it production-grade.
7584

7685
### Migrate Database

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ Navigate to the Google Cloud Console and create a new firewall rule:
2929

3030
Fill in the rule details to allow traffic on port 8000:
3131

32-
- Set **Name** to `allow-django-8000`.
32+
- Set **Name** to `allow-tcp-8000`.
3333
- Select your network (the default is `default`; your organization may use a different network).
3434
- Set **Direction of traffic** to **Ingress**.
3535
- Set **Action on match** to **Allow**.
3636
- Set **Targets** to **Specified target tags**.
37-
- Enter `django-server` in the **Target tags** field.
37+
- Enter `allow-tcp-8000` in the **Target tags** field.
3838
- Set **Source IPv4 ranges** to `0.0.0.0/0` (allows traffic from any IP address; restrict this in production).
3939

40-
![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")
40+
![Screenshot showing the firewall rule configuration form. The Name field shows allow-tcp-8000, Direction is set to Ingress, and Targets is set to Specified target tags. alt-text#center](images/network-rule.png "Firewall rule configuration")
4141

4242
## Specify the port and protocol
4343

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

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,80 +10,86 @@ layout: learningpathall
1010

1111
After connecting to your SUSE Linux Enterprise Server (SLES) VM using SSH, you'll install the Google Cloud CLI, update your system, install Python 3.11, and set up a virtual environment for your Django project.
1212

13-
## Install Google Cloud CLI (gcloud)
14-
15-
The Google Cloud CLI is required to authenticate with GCP and allow your Django application VM to interact with Google Cloud services such as GKE, Cloud SQL, Artifact Registry, Memorystore, and to build, deploy, and operate the Django platform.
13+
## Prepare the system
1614

17-
### Download gcloud SDK (Arm64)
15+
Update the system packages and install dependencies:
1816

1917
```console
20-
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-arm.tar.gz
18+
sudo zypper refresh
19+
sudo zypper update -y
20+
sudo zypper install -y curl git tar gzip
2121
```
2222

23-
### Extract and install gcloud
23+
### Install Python 3.11
2424

25-
```console
26-
tar -xzf google-cloud-cli-linux-arm.tar.gz
27-
cd google-cloud-sdk
28-
./install.sh
25+
Install Python 3.11:
26+
27+
```bash
28+
sudo zypper install -y python311
29+
which python3.11
2930
```
3031

31-
Accept the default options during installation.
32+
Verify that Python and pip are installed correctly:
3233

33-
### Initialize gcloud
34+
```bash
35+
python3.11 --version
36+
pip3.11 --version
37+
```
38+
The output should be similar to:
3439

35-
```console
36-
source ~/.bashrc
37-
gcloud init
40+
```output
41+
Python 3.11.10
42+
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
3843
```
3944

40-
During initialization:
45+
## Install Google Cloud CLI (gcloud)
4146

42-
- Select the correct project (for example: imperial-time-xxxxxx)
43-
- Choose the default region (for example: us-central1)
47+
The Google Cloud CLI is required to authenticate with GCP and allow your Django application VM to interact with Google Cloud services such as GKE, Cloud SQL, Artifact Registry, Memorystore, and to build, deploy, and operate the Django platform.
4448

45-
### Verify authentication
49+
### Install Google Cloud SDK (gcloud)
50+
51+
The Google Cloud SDK is required to create and manage GKE clusters.
52+
53+
Download and extract:
4654

4755
```console
48-
gcloud auth list
56+
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-460.0.0-linux-arm.tar.gz
57+
tar -xvf google-cloud-sdk-460.0.0-linux-arm.tar.gz
4958
```
5059

51-
You should see an output similar to:
52-
```output
53-
Credentialed Accounts
54-
ACTIVE ACCOUNT
55-
* <PROJECT_NUMBER>-compute@developer.gserviceaccount.com
56-
```
60+
Install gcloud:
5761

58-
## Update your system
62+
```console
63+
./google-cloud-sdk/install.sh
64+
```
5965

60-
Begin by refreshing your package list and upgrading installed software to ensure you have the latest versions and security patches:
66+
After installation completes, exit and reconnect to apply the PATH changes:
6167

6268
```console
63-
sudo zypper refresh
64-
sudo zypper update -y
69+
exit
6570
```
6671

67-
## Install Python 3.11 and development tools
72+
### Initialize gcloud
6873

69-
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:
74+
Authenticate and configure the Google Cloud CLI:
7075

7176
```console
72-
sudo zypper install -y python311 python311-pip python311-devel git gcc make
77+
gcloud init
7378
```
7479

75-
Verify that Python and pip are installed correctly:
80+
During initialization, select **Login with a new account**. You'll be prompted to authenticate using your browser and receive an auth code to copy back. Select the project you want to use and choose default settings when unsure.
7681

77-
```bash
78-
python3.11 --version
79-
pip3.11 --version
80-
```
82+
### Verify authentication
8183

82-
The output is similar to:
84+
```console
85+
gcloud auth list
86+
```
8387

88+
You should see an output similar to:
8489
```output
85-
Python 3.11.10
86-
pip 22.3.1 from /usr/lib/python3.11/site-packages/pip (python 3.11)
90+
Credentialed Accounts
91+
ACTIVE ACCOUNT
92+
* <PROJECT_NUMBER>-compute@developer.gserviceaccount.com
8793
```
8894

8995
## Create a project directory and virtual environment
@@ -127,7 +133,7 @@ django-admin --version
127133
The output is similar to:
128134

129135
```output
130-
5.2.8
136+
5.2.10
131137
```
132138

133139
## Summary and what's next

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

Lines changed: 104 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,59 +35,96 @@ GKE (Axion Arm64)
3535
```
3636
This architecture represents a production-grade microservice deployment where compute runs on Arm, while data services are provided through fully managed GCP offerings over private networking.
3737

38-
### Install Docker (Container Runtime)
39-
Docker is required to build, run, and test container images locally before pushing them to Artifact Registry.
38+
## Enable the SUSE Containers module
4039

41-
**Update system packages and install prerequisites:**
40+
Enable the SUSE Containers Module to ensure that Docker and container-related tools are fully supported.
41+
``` console
42+
sudo SUSEConnect -p sle-module-containers/15.5/arm64
43+
sudo SUSEConnect --list-extensions | grep Containers
44+
```
45+
46+
Verify that the output shows the Containers module as **Activated**.
47+
48+
## Install Docker
49+
50+
Docker is required to run KinD and the Kubernetes control plane components. Install Docker, start the service, and add your user to the docker group:
4251

4352
```console
44-
sudo zypper update
45-
sudo zypper install -y ca-certificates curl gnupg
53+
sudo zypper refresh
54+
sudo zypper install -y docker
55+
sudo systemctl enable --now docker
56+
sudo usermod -aG docker $USER
57+
exit
4658
```
4759

48-
**Install Docker using the official installation script:**
60+
Exit the current shell and reconnect to the virtual machine so that the group membership change takes effect. Then verify that Docker is running:
4961

5062
```console
51-
curl -fsSL https://get.docker.com | sudo sh
63+
docker ps
64+
```
65+
66+
Output similar to the following indicates that Docker is installed and accessible:
67+
68+
```output
69+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5270
```
5371

54-
**Allow the current user to run Docker without sudo:**
72+
## Install kubectl (Kubernetes CLI)
73+
74+
Install the kubectl command-line tool for interacting with Kubernetes clusters:
5575

5676
```console
57-
sudo usermod -aG docker $USER
58-
newgrp docker
77+
curl -LO https://dl.k8s.io/release/v1.30.1/bin/linux/arm64/kubectl
78+
chmod +x kubectl
79+
sudo mv kubectl /usr/local/bin/
5980
```
6081

61-
**Verify Docker installation:**
82+
## Verify kubectl
83+
84+
Confirm that kubectl is installed and accessible from the command line:
6285

6386
```console
64-
docker run hello-world
87+
kubectl version --client
6588
```
6689

67-
A successful message confirms that Docker is installed and working correctly.
90+
Output similar to the following indicates that kubectl is installed correctly:
91+
```output
92+
Client Version: v1.30.1
93+
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
94+
```
6895

69-
### Install kubectl (Kubernetes CLI)
70-
kubectl is the command-line tool used to interact with Kubernetes clusters, deploy workloads, and manage resources.
96+
### Get the list of Google project IDs
7197

72-
Download the latest stable Arm64 binary:
98+
Retrieve the list of project IDs:
7399

74100
```console
75-
curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl
101+
gcloud projects list
102+
```
103+
104+
The output is similar to:
105+
106+
```output
107+
PROJECT_ID NAME PROJECT_NUMBER
108+
arm-lp-test arm-lp-test 834184475014
76109
```
77110

78-
**Make the binary executable and move it to PATH:**
111+
Note the **PROJECT_ID** for use in the next step.
112+
113+
### Set the active project
114+
115+
Ensure the correct GCP project is selected:
79116

80117
```console
81-
chmod +x kubectl
82-
sudo mv kubectl /usr/local/bin/
118+
gcloud config set project <YOUR_PROJECT_ID>
83119
```
84120

85-
**Verify kubectl installation:**
121+
Replace `<YOUR_PROJECT_ID>` with your actual project ID from the previous step.
122+
123+
### Install the auth plugin for gcloud
86124

87125
```console
88-
kubectl version --client
126+
gcloud components install gke-gcloud-auth-plugin
89127
```
90-
This confirms that the Kubernetes client is correctly installed on the VM.
91128

92129
### Create Artifact Registry
93130
Artifact Registry is used to store and distribute the Docker images for your Django application. This ensures that all Kubernetes nodes pull trusted, versioned images from a private Google-managed repository.
@@ -99,6 +136,7 @@ gcloud artifacts repositories create django-arm \
99136
```
100137

101138
```console
139+
sudo chmod 777 /etc/containers
102140
gcloud auth configure-docker us-central1-docker.pkg.dev
103141
```
104142
You now have a secure, private Docker registry ready to store Arm-based application images for GKE.
@@ -110,12 +148,54 @@ We initially create it with a small x86 pool so the cluster can bootstrap.
110148
```console
111149
gcloud container clusters create django-axion-cluster \
112150
--zone us-central1-a \
151+
--machine-type c4a-standard-4 \
113152
--num-nodes 1 \
114-
--machine-type e2-medium \
115153
--enable-ip-alias
116154
```
155+
117156
You now have a running GKE cluster ready to accept custom node pools and workloads.
118157

158+
### Configure kubectl access to GKE
159+
160+
Fetch cluster credentials:
161+
162+
```console
163+
gcloud container clusters get-credentials django-axion-cluster \
164+
--zone us-central1-a
165+
```
166+
167+
### Verify cluster access
168+
169+
Confirm Kubernetes access:
170+
171+
```console
172+
kubectl get nodes
173+
```
174+
175+
You should see an output similar to:
176+
```output
177+
NAME STATUS ROLES AGE VERSION
178+
gke-django-axion-cluster-default-pool-156e91c3-wdsb Ready <none> 34m v1.33.5-gke.2072000
179+
```
180+
181+
All nodes should be in **Ready** state and the Kubernetes control plane should be accessible.
182+
183+
### Taint the cluster nodes for arm64 support
184+
185+
Taint the nodes to ensure proper scheduling on arm64 VMs. For each node starting with **gke**, run the following taint command.
186+
187+
{{% notice Note %}}
188+
Note the required "-" at the end... its needed!
189+
{{% /notice %}}
190+
191+
For example using the node IDs in the output above:
192+
193+
```console
194+
kubectl taint nodes gke-django-axion-cluster-default-pool-156e91c3-wdsb kubernetes.io/arch=arm64:NoSchedule-
195+
```
196+
197+
Replace the node names with your actual node names from the previous command output.
198+
119199
### Add Axion (Arm64) Node Pool
120200
Axion (Arm64) nodes provide high performance per watt and cost-efficient compute.
121201
This pool will run all Django application workloads.

0 commit comments

Comments
 (0)