Files
jenkins-pipeline/k8s_yaml/s1/s1-lessie-agents.yaml

130 lines
4.5 KiB
YAML
Raw Normal View History

2025-11-07 11:25:23 +08:00
# ----------------------------
# Deployment
# ----------------------------
apiVersion: apps/v1
kind: Deployment
metadata:
2025-11-07 18:06:59 +08:00
name: s1-lessie-agents-deployment
namespace: sit
2025-11-07 11:25:23 +08:00
labels:
2025-11-07 18:06:59 +08:00
app: s1-lessie-agents
environment: s1
2025-11-07 11:25:23 +08:00
project: lessie
spec:
replicas: 1
selector:
matchLabels:
2025-11-07 18:06:59 +08:00
app: s1-lessie-agents
environment: s1
2025-11-07 11:25:23 +08:00
project: lessie
strategy:
type: RollingUpdate # 滚动更新策略
rollingUpdate:
maxSurge: 1 # 最大新增副本数(先加)
maxUnavailable: 0 # 最大不可用副本数(不减)
template:
metadata:
labels:
2025-11-07 18:06:59 +08:00
app: s1-lessie-agents
environment: s1
2025-11-07 11:25:23 +08:00
project: lessie
spec:
imagePullSecrets:
- name: dxin-image-repository # 镜像仓库凭证Secret
volumes:
- name: aws-credentials-volume # aws-credentials 卷文件
configMap:
name: aws-credentials
- name: google-credentials-volume
configMap:
name: google-credentials
- name: lessie-logs-volume
hostPath:
path: /data/logs/lessie-agents/
type: DirectoryOrCreate
containers:
2025-11-20 14:51:44 +08:00
- name: lessie-agents # 容器名称
2025-11-07 18:06:59 +08:00
image: uswccr.ccs.tencentyun.com/lessiesit/lessie-sourcing-agents:v0.0.2 # 容器镜像
2025-11-07 11:25:23 +08:00
imagePullPolicy: Always # 镜像拉取策略拉
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: APP_ENV
value: "s1"
- name: APP_PORT
value: "8000"
- name: GUNICORN_WORKERS
value: "2"
- name: MAX_REQUESTS
value: "200"
- name: MAX_REQUESTS_JITTER
value: "50"
ports:
- containerPort: 8000 # 容器暴露的端口
resources:
requests:
cpu: "0.5" # 容器请求分配0.5个CPU核心这不是实际占用但调度会以这里进行参考
memory: "2Gi" # 容器请求分配1Gi内存这会实际预留
limits:
cpu: "2" # 最多可以使用2个CPU核心
2025-11-07 18:06:59 +08:00
memory: "10Gi" # 容器最多可以使用10Gi内存
2025-11-07 11:25:23 +08:00
volumeMounts:
- name: aws-credentials-volume
mountPath: /root/.aws/
- name: google-credentials-volume
mountPath: /root/.google/
- name: lessie-logs-volume
mountPath: /data/webapps/lessie_sourcing_agents/logs/
subPathExpr: lessie-agents-$(POD_NAME)
2025-11-07 18:06:59 +08:00
readinessProbe: # 就绪探针,用于判断容器是否已准备好接收流量
httpGet:
path: /health
port: 8000
initialDelaySeconds: 20 # 就绪探测在容器启动后等待多少秒才开始第一次探测(避免应用启动未完成即被判为不就绪)
periodSeconds: 10 # 就绪探测的间隔秒数,每隔多少秒执行一次探测
timeoutSeconds: 5 # 单次就绪探测的超时时间(秒),超过则该次探测视为失败
failureThreshold: 3 # 连续失败多少次后认为就绪探测失败Pod 不再被视为就绪)
livenessProbe: # 存活探针,用于判断容器是否仍然健康,失败会触发重启
httpGet:
path: /health
port: 8000
initialDelaySeconds: 10 # 存活探测在容器启动后等待多少秒才开始第一次探测
periodSeconds: 30 # 存活探测的间隔秒数
timeoutSeconds: 5 # 单次存活探测的超时时间(秒)
failureThreshold: 3 # 连续失败多少次后认为容器不健康并触发重启
2025-11-07 11:25:23 +08:00
---
# ----------------------------
# Service
2025-11-07 18:06:59 +08:00
# 集群内部http://s1-lessie-agents-svc.sit.svc.cluster.local:8000
# curl -v -X POST http://xxxxxxx:8000/api/chat/stream -H "Content-Type: application/json" -d '{"message": "hello"}'
2025-11-07 11:25:23 +08:00
# ----------------------------
apiVersion: v1
kind: Service
metadata:
2025-11-07 18:06:59 +08:00
name: s1-lessie-agents-svc
namespace: sit
2025-11-07 11:25:23 +08:00
labels:
2025-11-07 18:06:59 +08:00
app: s1-lessie-agents
environment: s1
2025-11-07 11:25:23 +08:00
project: lessie
spec:
2025-11-07 18:06:59 +08:00
type: ClusterIP
2025-11-07 11:25:23 +08:00
selector: # 必须匹配 Deployment 的 labels 才能关联 Pod
2025-11-07 18:06:59 +08:00
app: s1-lessie-agents
environment: s1
2025-11-07 11:25:23 +08:00
project: lessie
ports:
- name: http
port: 8000 # ClusterIP 内部端口
targetPort: 8000 # 容器端口
2025-11-15 18:18:21 +08:00