Files
aiops/deploy/k8s/ingress.yaml
T
Logan 4631b02f13 feat: 三种部署方式 — embed单容器 + 二进制部署 + K8s
新增三种部署方式(原有 docker-compose 不受影响):

1. Docker embed 单容器 (docker-compose.embed.yml):
   - go:embed 前端嵌入后端二进制
   - 不需要 nginx 容器,3容器→2容器
   - 镜像仅 54.8MB (vs 原来 1.16GB)
   - 用法: make docker-embed

2. 二进制部署 (deploy/binary/):
   - make build-binary 生成单二进制
   - install.sh 自动创建 systemd 服务
   - 适合无 Docker 环境
   - 用法: scp aiops + install.sh, bash install.sh install

3. Kubernetes 部署 (deploy/k8s/):
   - devops 命名空间全套 yaml
   - MySQL StatefulSet + Redis StatefulSet + Backend Deployment
   - ConfigMap + Secret + Ingress
   - 用法: kubectl apply -f deploy/k8s/

核心改动:
- backend/cmd/embed.go: go:embed 前端 + SPA fallback 路由
- backend/Dockerfile.embed: 四阶段构建 (前端→后端embed→agent→runtime)
- Makefile: build-binary + docker-embed 目标
- deploy/README.md: 四种部署方式对比文档
2026-06-21 14:20:29 +08:00

60 lines
2.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ingress.yaml — Ingress 入口路由 (nginx-ingress)
# ----------------------------------------------------------------------------
# 路由规则:
# /api/* -> aiops-backend:8080 (后端 API)
# /ws/* -> aiops-backend:8080 (WebSocket 长连接)
# / -> aiops-backend:80 (go:embed 前端 SPA)
#
# 前提: 集群已安装 nginx Ingress Controller。
# 部署前请修改 host (aiops.local) 与 ingressClassName 为实际值。
# 部署: kubectl apply -f ingress.yaml
# ----------------------------------------------------------------------------
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aiops-ingress
namespace: devops
labels:
app.kubernetes.io/name: aiops
annotations:
# WebSocket 长连接支持(/ws)
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
# 文件上传大小(与后端 upload.max_size 配合)
nginx.ingress.kubernetes.io/proxy-body-size: "100m"
# 显式转发 WebSocket 升级头
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
spec:
ingressClassName: nginx # 按集群实际 IngressClass 调整
rules:
- host: aiops.local # TODO: 修改为实际访问域名
http:
paths:
# ---- API ----
- path: /api
pathType: Prefix
backend:
service:
name: aiops-backend
port:
number: 8080
# ---- WebSocket ----
- path: /ws
pathType: Prefix
backend:
service:
name: aiops-backend
port:
number: 8080
# ---- 前端 (go:embed, 默认兜底) ----
- path: /
pathType: Prefix
backend:
service:
name: aiops-backend
port:
number: 80