- 新增 MySQL、Redis、Server 和 Nginx 的 Deployment、Service 和 ConfigMap 文件 - 添加初始化 SQL 文件和 Nginx 配置文件 - 设置环境变量和持久化存储
107 lines
2.7 KiB
YAML
107 lines
2.7 KiB
YAML
# Nginx Deployment
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: nginx
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: nginx
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: nginx
|
|
spec:
|
|
containers:
|
|
- name: nginx
|
|
image: m.daocloud.io/docker.io/nginx:1.23.0
|
|
ports:
|
|
- containerPort: 80
|
|
- containerPort: 443
|
|
volumeMounts:
|
|
- name: nginx-config
|
|
mountPath: /etc/nginx/nginx.conf
|
|
subPath: nginx.conf
|
|
- name: nginx-html
|
|
mountPath: /usr/share/nginx/html/yudao-admin-ui
|
|
imagePullSecrets:
|
|
- name: my-registry-nginx-key
|
|
volumes:
|
|
- name: nginx-config
|
|
configMap:
|
|
name: nginx-config
|
|
- name: nginx-html
|
|
hostPath:
|
|
path: /host/dist-prod
|
|
type: Directory
|
|
---
|
|
# Nginx Service
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: nginx
|
|
spec:
|
|
ports:
|
|
- name: http
|
|
port: 80
|
|
targetPort: 80
|
|
- name: https
|
|
port: 443
|
|
targetPort: 443
|
|
selector:
|
|
app: nginx
|
|
---
|
|
# Nginx ConfigMap
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: nginx-config
|
|
data:
|
|
nginx.conf: |
|
|
user nginx;
|
|
worker_processes auto;
|
|
error_log /var/log/nginx/error.log;
|
|
pid /run/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
access_log /var/log/nginx/access.log main;
|
|
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout 65;
|
|
types_hash_max_size 2048;
|
|
charset utf-8;
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;# 替换为你的域名或外网IP
|
|
charset utf-8;
|
|
location / { # 前端配置
|
|
root /usr/share/nginx/html/yudao-admin-ui;
|
|
index index.html index.htm;
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
location /admin-api/ { # 后端代理配置
|
|
proxy_pass http://yudao-server:48080/admin-api/; # 替换为实际后端IP
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header REMOTE-HOST $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
}
|
|
|
|
}
|