This setup uses Local Persistent Volumes. You need to create the data storage directories on a node within your cluster (the default is the `master` node in `pv.yaml`).
```bash
# Log in to your master node
# 通过SSH登录到主节点(master node)
# user为登录用户名,master-node为主节点的地址(可是IP或域名)
ssh user@master-node
# Create the required storage directories
# 创建所需的存储目录(使用sudo获取管理员权限)
# -p 选项确保在父目录不存在时自动创建,避免报错
# 用于数据库(如MySQL)的本地存储目录
sudo mkdir -p /mnt/local-storage-db
# 用于djangoblog应用的本地存储目录
sudo mkdir -p /mnt/local-storage-djangoblog
# 通用资源存储目录
sudo mkdir -p /mnt/resource/
# 用于Elasticsearch的本地存储目录
sudo mkdir -p /mnt/local-storage-elasticsearch
# Log out from the node
# 从节点退出,返回本地终端
exit
```
**Note**: If you wish to store data on a different node or use different paths, you must modify the `nodeAffinity` and `local.path` settings in the `deploy/k8s/pv.yaml` file.
@ -54,13 +67,16 @@ exit
After creating the directories, apply the storage-related configurations:
```bash
# Apply the StorageClass
# 应用StorageClass配置(存储类,用于定义持久化存储的类型和属性)
# StorageClass用于动态供应持久卷(PV),简化存储管理
kubectl apply -f deploy/k8s/storageclass.yaml
# Apply the PersistentVolumes (PVs)
# 应用持久卷(PersistentVolumes, PVs)配置
# PV是集群中的一块存储资源,由管理员预先创建或通过StorageClass动态生成
kubectl apply -f deploy/k8s/pv.yaml
# Apply the PersistentVolumeClaims (PVCs)
# 应用持久卷声明(PersistentVolumeClaims, PVCs)配置
# PVC是用户对存储资源的请求,用于绑定PV并为Pod提供持久化存储
kubectl apply -f deploy/k8s/pvc.yaml
```
@ -73,10 +89,12 @@ Before deploying the application, you need to edit the `deploy/k8s/configmap.yam
- `DJANGO_MYSQL_PASSWORD` and `MYSQL_ROOT_PASSWORD`: Change to your own secure database password.
@ -118,23 +141,32 @@ kubectl get ingress -n djangoblog
Similar to the Docker deployment, you need to get a shell into the DjangoBlog application Pod to perform database initialization and create a superuser on the first run.