fengling-gateway/k8s/base/deployment.yaml
movingsam 6ea7f6c958 feat: add k8s deployment manifests and fix docker workflow env
- Add k8s/base/deployment.yaml with Namespace, ConfigMap, Secret, Deployment and Service for YARP gateway
- Fix duplicate REGISTRY/IMAGE_NAME env vars in docker.yml
2026-02-28 15:24:40 +08:00

141 lines
3.5 KiB
YAML

apiVersion: v1
kind: Namespace
metadata:
name: fengling
labels:
app.kubernetes.io/name: fengling
app.kubernetes.io/managed-by: kubectl
---
apiVersion: v1
kind: ConfigMap
metadata:
name: yarp-gateway-config
namespace: fengling
labels:
app: yarp-gateway
data:
ASPNETCORE_ENVIRONMENT: "Production"
Logging__LogLevel__Default: "Information"
Logging__LogLevel__Microsoft__AspNetCore: "Warning"
Logging__LogLevel__Yarp__ReverseProxy: "Information"
Serilog__MinimumLevel: "Information"
Kestrel__Endpoints__Http__Url: "http://0.0.0.0:8080"
---
apiVersion: v1
kind: Secret
metadata:
name: yarp-gateway-secret
namespace: fengling
labels:
app: yarp-gateway
type: Opaque
stringData:
# PostgreSQL 连接字符串
ConnectionStrings__DefaultConnection: "Host=postgres;Port=5432;Database=fengling_gateway;Username=movingsam;Password=${POSTGRES_PASSWORD}"
# Redis 连接字符串
Redis__ConnectionString: "redis:6379"
# JWT 配置
Jwt__Authority: "https://your-auth-server.com"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: yarp-gateway
namespace: fengling
labels:
app: yarp-gateway
version: v1
spec:
replicas: 2
selector:
matchLabels:
app: yarp-gateway
template:
metadata:
labels:
app: yarp-gateway
version: v1
spec:
containers:
- name: yarp-gateway
image: gitea.shtao1.cn/fengling/YarpGateway:latest
imagePullPolicy: Always
ports:
- name: http
containerPort: 8080
protocol: TCP
- name: metrics
containerPort: 8081
protocol: TCP
env:
- name: ASPNETCORE_ENVIRONMENT
valueFrom:
configMapKeyRef:
name: yarp-gateway-config
key: ASPNETCORE_ENVIRONMENT
- name: ConnectionStrings__DefaultConnection
valueFrom:
secretKeyRef:
name: yarp-gateway-secret
key: ConnectionStrings__DefaultConnection
- name: Redis__ConnectionString
valueFrom:
secretKeyRef:
name: yarp-gateway-secret
key: Redis__ConnectionString
- name: Jwt__Authority
valueFrom:
secretKeyRef:
name: yarp-gateway-secret
key: Jwt__Authority
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: http
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
volumeMounts:
- name: logs
mountPath: /app/logs
volumes:
- name: logs
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: yarp-gateway
namespace: fengling
labels:
app: yarp-gateway
spec:
type: ClusterIP
ports:
- name: http
port: 80
targetPort: http
protocol: TCP
- name: metrics
port: 8081
targetPort: metrics
protocol: TCP
selector:
app: yarp-gateway