125 lines
3.4 KiB
YAML
125 lines
3.4 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:
|
|
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
|
|
# ── 运行时环境变量 (仅覆盖代码默认值, 其余走 viper 默认) ──
|
|
env:
|
|
- name: TZ
|
|
value: Asia/Shanghai
|
|
- 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"
|
|
- name: JWT_SECRET
|
|
value: "aiops-jwt-secret-key-2026"
|
|
|
|
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
|