变更内容: - 添加 Kubernetes 部署配置文件,包括 API Deployment、Worker Deployment 和 Redis Deployment。 - 新增 Service 定义,支持 API、Metrics 和 Redis 的集群访问。 - 配置 ConfigMap,用于全局共享环境变量。 - 编写 Kubernetes 部署指南文档,包含快速部署步骤、建议配置及故障排查方法。 - 提升系统的可扩展性和容器编排能力,适配生产环境使用。
66 lines
1.2 KiB
YAML
66 lines
1.2 KiB
YAML
# Kubernetes Service 配置
|
||
# 包含:API Service、Metrics Service、Redis Service
|
||
|
||
---
|
||
# API Service - 对外暴露 HTTP 服务
|
||
apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: functional-scaffold-api
|
||
labels:
|
||
app: functional-scaffold
|
||
component: api
|
||
spec:
|
||
type: ClusterIP
|
||
ports:
|
||
- port: 80
|
||
targetPort: 8000
|
||
protocol: TCP
|
||
name: http
|
||
selector:
|
||
app: functional-scaffold
|
||
component: api
|
||
|
||
---
|
||
# Metrics Service - Prometheus 抓取指标
|
||
apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: functional-scaffold-metrics
|
||
labels:
|
||
app: functional-scaffold
|
||
component: api
|
||
annotations:
|
||
prometheus.io/scrape: "true"
|
||
prometheus.io/port: "8000"
|
||
prometheus.io/path: "/metrics"
|
||
spec:
|
||
type: ClusterIP
|
||
ports:
|
||
- port: 8000
|
||
targetPort: 8000
|
||
protocol: TCP
|
||
name: metrics
|
||
selector:
|
||
app: functional-scaffold
|
||
component: api
|
||
|
||
---
|
||
# Redis Service - 内部 Redis 服务
|
||
apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: functional-scaffold-redis
|
||
labels:
|
||
app: functional-scaffold
|
||
component: redis
|
||
spec:
|
||
type: ClusterIP
|
||
ports:
|
||
- port: 6379
|
||
targetPort: 6379
|
||
protocol: TCP
|
||
name: redis
|
||
selector:
|
||
app: functional-scaffold
|
||
component: redis |