Files
aiops/deploy/kubernetes/deployment.yaml
T
Logan.Li 339b24a579 优化 K8s 页面布局与 local 模式部署收尾
P0-P1:
- Dockerfile.embed 启用 CGO 支持 SQLite+redka
- K8s scale>1 时警告 local 模式数据不共享

K8s UI:
- 移除侧边栏资源用量/容量分析及资源页横向 Tab 栏
- 修复事件路由(/workloads/events)与 Deployment 事件过滤
- 网络/配置/存储统一 YamlViewer 编辑,加大编辑弹窗
2026-06-26 13:36:27 +08:00

132 lines
3.9 KiB
YAML

# deployment.yaml — AIOps 应用 (embed 前端嵌入后端, 单容器单端口)
# ----------------------------------------------------------------------------
# - 镜像 aiops:embed(前端通过 go:embed 内嵌进同一二进制)
# - 单端口 8080 = API + WebSocket + 前端 SPA 静态资源
# - 配置优先级: 环境变量 > config.yaml > 默认值 (viper AutomaticEnv)
# - 环境变量命名: 配置键 database.host → DATABASE_HOST (全大写, 点变下划线)
# - 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:
# MODE=local 使用 SQLite,必须保持 1 副本(多副本数据不共享)// Logan.Li
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
enableServiceLinks: false
containers:
- name: aiops
image: 10.10.10.72/library/aiops:embed
imagePullPolicy: Always
ports:
- name: http
containerPort: 8080
# ── 运行时环境变量 (环境变量 > config.yaml > 默认值) ──
# mode=local → SQLite + redka 本地存储,无需外部 MySQL/Redis // Logan.Li
# 切换集群模式时改为 mode=release 并取消注释下方 DATABASE_/REDIS_ 变量
env:
- name: TZ
value: Asia/Shanghai
- name: MODE
value: local
- name: JWT_SECRET
value: "aiops-jwt-secret-key-2026"
# --- 集群模式(mode=release)时启用 ---
# - name: DATABASE_DRIVER
# value: "mysql"
# - name: DATABASE_HOST
# value: "10.10.10.75"
# - name: DATABASE_USER
# value: "root"
# - name: DATABASE_PASSWORD
# value: "aiops_root_2026"
# - name: DATABASE_DBNAME
# value: "aiops"
# - name: REDIS_DRIVER
# value: "redis"
# - name: REDIS_HOST
# value: "10.10.10.75"
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
persistentVolumeClaim:
claimName: aiops-data
---
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