feat: 初始化零工后端代码
This commit is contained in:
90
gig-poc/infrastructure/k8s/api.yaml
Normal file
90
gig-poc/infrastructure/k8s/api.yaml
Normal 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
|
||||
24
gig-poc/infrastructure/k8s/ingress.yaml
Normal file
24
gig-poc/infrastructure/k8s/ingress.yaml
Normal 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
|
||||
9
gig-poc/infrastructure/k8s/kustomization.yaml
Normal file
9
gig-poc/infrastructure/k8s/kustomization.yaml
Normal 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
|
||||
4
gig-poc/infrastructure/k8s/namespace.yaml
Normal file
4
gig-poc/infrastructure/k8s/namespace.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: gig-poc
|
||||
41
gig-poc/infrastructure/k8s/redis.yaml
Normal file
41
gig-poc/infrastructure/k8s/redis.yaml
Normal 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
|
||||
61
gig-poc/infrastructure/k8s/web.yaml
Normal file
61
gig-poc/infrastructure/k8s/web.yaml
Normal 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
|
||||
Reference in New Issue
Block a user