密钥写死,处理报错
This commit is contained in:
129
k8s/deployment.yaml
Normal file
129
k8s/deployment.yaml
Normal file
@@ -0,0 +1,129 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: flask-prompt-master
|
||||
labels:
|
||||
app: flask-prompt-master
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: flask-prompt-master
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: flask-prompt-master
|
||||
spec:
|
||||
containers:
|
||||
- name: app
|
||||
image: flask-prompt-master:latest
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
env:
|
||||
- name: FLASK_ENV
|
||||
value: "production"
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: flask-secrets
|
||||
key: database-url
|
||||
- name: SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: flask-secrets
|
||||
key: secret-key
|
||||
- name: LLM_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: flask-secrets
|
||||
key: llm-api-key
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "512Mi"
|
||||
cpu: "500m"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 5000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 5000
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
volumeMounts:
|
||||
- name: logs
|
||||
mountPath: /app/logs
|
||||
- name: uploads
|
||||
mountPath: /app/uploads
|
||||
volumes:
|
||||
- name: logs
|
||||
persistentVolumeClaim:
|
||||
claimName: logs-pvc
|
||||
- name: uploads
|
||||
persistentVolumeClaim:
|
||||
claimName: uploads-pvc
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: flask-prompt-master-service
|
||||
spec:
|
||||
selector:
|
||||
app: flask-prompt-master
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 5000
|
||||
type: ClusterIP
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: flask-prompt-master-ingress
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- flask-prompt-master.example.com
|
||||
secretName: flask-prompt-master-tls
|
||||
rules:
|
||||
- host: flask-prompt-master.example.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: flask-prompt-master-service
|
||||
port:
|
||||
number: 80
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: logs-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: uploads-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
113
k8s/monitoring.yaml
Normal file
113
k8s/monitoring.yaml
Normal file
@@ -0,0 +1,113 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: flask-monitor
|
||||
labels:
|
||||
app: flask-monitor
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: flask-monitor
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: flask-monitor
|
||||
spec:
|
||||
containers:
|
||||
- name: monitor
|
||||
image: flask-prompt-master-monitor:latest
|
||||
env:
|
||||
- name: APP_URL
|
||||
value: "http://flask-prompt-master-service:80"
|
||||
- name: MONITOR_INTERVAL
|
||||
value: "30"
|
||||
resources:
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "256Mi"
|
||||
cpu: "200m"
|
||||
volumeMounts:
|
||||
- name: logs
|
||||
mountPath: /app/logs
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- python
|
||||
- -c
|
||||
- "import requests; requests.get('$APP_URL/health')"
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 60
|
||||
volumes:
|
||||
- name: logs
|
||||
persistentVolumeClaim:
|
||||
claimName: logs-pvc
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: flask-log-manager
|
||||
labels:
|
||||
app: flask-log-manager
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: flask-log-manager
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: flask-log-manager
|
||||
spec:
|
||||
containers:
|
||||
- name: log-manager
|
||||
image: flask-prompt-master-log-manager:latest
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
volumeMounts:
|
||||
- name: logs
|
||||
mountPath: /app/logs
|
||||
volumes:
|
||||
- name: logs
|
||||
persistentVolumeClaim:
|
||||
claimName: logs-pvc
|
||||
---
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: log-maintenance
|
||||
spec:
|
||||
schedule: "0 2 * * *" # 每天凌晨2点执行
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: log-maintenance
|
||||
image: flask-prompt-master-log-manager:latest
|
||||
command: ["python", "log_manager.py"]
|
||||
volumeMounts:
|
||||
- name: logs
|
||||
mountPath: /app/logs
|
||||
volumes:
|
||||
- name: logs
|
||||
persistentVolumeClaim:
|
||||
claimName: logs-pvc
|
||||
restartPolicy: OnFailure
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: monitor-config
|
||||
data:
|
||||
monitor-interval: "30"
|
||||
alert-threshold: "2.0"
|
||||
retention-days: "30"
|
||||
max-file-size: "10485760" # 10MB
|
||||
Reference in New Issue
Block a user