feat: 初始化零工后端代码

This commit is contained in:
Daniel
2026-04-01 14:19:25 +08:00
parent c6fabe262c
commit 84f8be7c0e
41 changed files with 2813 additions and 147 deletions

View File

@@ -0,0 +1,90 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: gig-poc-api
namespace: gig-poc
spec:
replicas: 3
selector:
matchLabels:
app: gig-poc-api
template:
metadata:
labels:
app: gig-poc-api
spec:
containers:
- name: api
image: gig-poc-api:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8000
env:
- name: APP_ENV
value: production
- name: CACHE_BACKEND
value: redis
- name: REDIS_URL
value: redis://gig-poc-redis:6379/0
- name: INGEST_ASYNC_ENABLED
value: "true"
- name: MATCH_ASYNC_ENABLED
value: "true"
- name: MATCH_CACHE_ENABLED
value: "true"
- name: QUERY_CACHE_ENABLED
value: "true"
- name: APP_RATE_LIMIT_PER_MINUTE
value: "3000"
resources:
requests:
cpu: "500m"
memory: "512Mi"
limits:
cpu: "2"
memory: "2Gi"
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 10
periodSeconds: 10
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 30
periodSeconds: 15
---
apiVersion: v1
kind: Service
metadata:
name: gig-poc-api
namespace: gig-poc
spec:
selector:
app: gig-poc-api
ports:
- name: http
port: 8000
targetPort: 8000
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: gig-poc-api-hpa
namespace: gig-poc
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: gig-poc-api
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70

View File

@@ -0,0 +1,24 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gig-poc-ingress
namespace: gig-poc
spec:
rules:
- host: gig-poc.local
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: gig-poc-api
port:
number: 8000
- path: /
pathType: Prefix
backend:
service:
name: gig-poc-web
port:
number: 80

View File

@@ -0,0 +1,9 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: gig-poc
resources:
- namespace.yaml
- redis.yaml
- api.yaml
- web.yaml
- ingress.yaml

View File

@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: gig-poc

View File

@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: gig-poc-redis
namespace: gig-poc
spec:
replicas: 1
selector:
matchLabels:
app: gig-poc-redis
template:
metadata:
labels:
app: gig-poc-redis
spec:
containers:
- name: redis
image: redis:7-alpine
args: ["redis-server", "--appendonly", "yes"]
ports:
- containerPort: 6379
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "512Mi"
---
apiVersion: v1
kind: Service
metadata:
name: gig-poc-redis
namespace: gig-poc
spec:
selector:
app: gig-poc-redis
ports:
- name: redis
port: 6379
targetPort: 6379

View File

@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: gig-poc-web
namespace: gig-poc
spec:
replicas: 2
selector:
matchLabels:
app: gig-poc-web
template:
metadata:
labels:
app: gig-poc-web
spec:
containers:
- name: web
image: gig-poc-web:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
resources:
requests:
cpu: "200m"
memory: "256Mi"
limits:
cpu: "1"
memory: "1Gi"
---
apiVersion: v1
kind: Service
metadata:
name: gig-poc-web
namespace: gig-poc
spec:
selector:
app: gig-poc-web
ports:
- name: http
port: 80
targetPort: 80
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: gig-poc-web-hpa
namespace: gig-poc
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: gig-poc-web
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70