方案1: docker-compose 双容器(原有,不变) 方案2: 二进制部署(go:embed 前端嵌入) - 修复 SPA fallback(c.FileFromFS 301 → c.Data 直接返回) - 二进制 22MB,内存 21.5MB - 支持全部 CLI 参数(--db-host --redis-host --port 等) 方案3: K8s 部署(hostNetwork + 外部 MySQL/Redis) - devops 声明空间 - embed 单容器 Deployment + NodePort Service - 健康检查改为 /version(/health 尚未实现) - hostNetwork 解决 K8s pod 网络到外部 MySQL 的连通性 新增: Dockerfile.embed, docker-compose.embed.yml, deploy/binary/
105 lines
2.7 KiB
YAML
105 lines
2.7 KiB
YAML
# deployment.yaml — AIOps 应用 (embed 前端嵌入后端, 单容器单端口)
|
|
# ----------------------------------------------------------------------------
|
|
# - 镜像 aiops:embed(前端通过 go:embed 内嵌进同一二进制)
|
|
# - 单端口 8080 = API + WebSocket + 前端 SPA 静态资源
|
|
# - 配置: ConfigMap aiops-config 挂载到 /app/config.yaml
|
|
# - Service: NodePort 30080 → 8080
|
|
#
|
|
# 部署: kubectl apply -f deployment.yaml
|
|
# ----------------------------------------------------------------------------
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: aiops
|
|
namespace: devops
|
|
labels:
|
|
app.kubernetes.io/name: aiops
|
|
app.kubernetes.io/component: app
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxSurge: 1
|
|
maxUnavailable: 0
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: aiops
|
|
app.kubernetes.io/component: app
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: aiops
|
|
app.kubernetes.io/component: app
|
|
spec:
|
|
hostNetwork: true
|
|
dnsPolicy: ClusterFirstWithHostNet
|
|
containers:
|
|
- name: aiops
|
|
image: aiops-aiops:latest
|
|
imagePullPolicy: IfNotPresent
|
|
ports:
|
|
- name: http
|
|
containerPort: 8080
|
|
env:
|
|
- name: TZ
|
|
value: Asia/Shanghai
|
|
volumeMounts:
|
|
- name: config
|
|
mountPath: /app/config.yaml
|
|
subPath: config.yaml
|
|
readOnly: true
|
|
- name: uploads
|
|
mountPath: /app/uploads
|
|
- name: data
|
|
mountPath: /app/data
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /version
|
|
port: 8080
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
timeoutSeconds: 3
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /version
|
|
port: 8080
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 30
|
|
timeoutSeconds: 5
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 256Mi
|
|
limits:
|
|
cpu: "1"
|
|
memory: 1Gi
|
|
volumes:
|
|
- name: config
|
|
configMap:
|
|
name: aiops-config
|
|
- name: uploads
|
|
emptyDir: {}
|
|
- name: data
|
|
emptyDir: {}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: aiops
|
|
namespace: devops
|
|
labels:
|
|
app.kubernetes.io/name: aiops
|
|
spec:
|
|
type: NodePort
|
|
selector:
|
|
app.kubernetes.io/name: aiops
|
|
app.kubernetes.io/component: app
|
|
ports:
|
|
- name: http
|
|
port: 8080
|
|
targetPort: 8080
|
|
nodePort: 30080
|
|
protocol: TCP
|