kt-template-online-api/k8s/prod/api.yaml

264 lines
6.7 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: kt-template-online-api
namespace: kt-prod
labels:
app: kt-template-online-api
spec:
replicas: 1
revisionHistoryLimit: 3
strategy:
type: Recreate
selector:
matchLabels:
app: kt-template-online-api
template:
metadata:
labels:
app: kt-template-online-api
spec:
containers:
- name: api
image: k3d-kt-registry.localhost:5000/kt-template-online-api:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 48085
env:
- name: NODE_ENV
value: production
- name: TZ
value: Asia/Shanghai
- name: DB_TIMEZONE
value: "+08:00"
- name: QQBOT_NAPCAT_IMAGE
value: kt-napcat-desktop-cn:desktop-cn-v8
- name: QQBOT_NAPCAT_DESKTOP_PROFILE_VERSION
value: desktop-cn-v8
- name: QQBOT_NAPCAT_SSH_KEY_PATH
value: /app/secrets/napcat-ssh/id_rsa
- name: QQBOT_PLUGIN_TASK_QUEUE_REDIS_PREFIX
value: kt:qqbot:plugin-task
- name: BANGDREAM_TSUGU_CACHE_ROOT
value: /data/qqbot/plugins/bangdream/cache
- name: NAPCAT_WEBUI_GATEWAY_INTERNAL_BASE_URL
value: http://kt-napcat-webui-gateway:48086
- name: NAPCAT_WEBUI_GATEWAY_PUBLIC_BASE_URL
value: /napcat-webui
# Jenkins 每次发布会从 Agent 私有 .env.production 重建这个 Secret。
envFrom:
- secretRef:
name: kt-template-online-api-env
volumeMounts:
- name: napcat-ssh-key
mountPath: /app/secrets/napcat-ssh
readOnly: true
- name: qqbot-plugin-data
mountPath: /data/qqbot/plugins
readinessProbe:
tcpSocket:
port: 48085
initialDelaySeconds: 8
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 6
livenessProbe:
tcpSocket:
port: 48085
initialDelaySeconds: 30
periodSeconds: 20
timeoutSeconds: 3
failureThreshold: 3
resources:
requests:
cpu: 100m
memory: 768Mi
limits:
cpu: 1000m
memory: 3072Mi
volumes:
- name: napcat-ssh-key
secret:
secretName: kt-qqbot-napcat-ssh-key
optional: true
defaultMode: 0400
- name: qqbot-plugin-data
hostPath:
path: /var/lib/rancher/k3s/kt-template-online-api/qqbot-plugins
type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
name: kt-template-online-api
namespace: kt-prod
labels:
app: kt-template-online-api
spec:
type: NodePort
selector:
app: kt-template-online-api
ports:
- name: http
port: 48085
targetPort: 48085
nodePort: 30085
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kt-qqbot-plugin-redis
namespace: kt-prod
labels:
app: kt-qqbot-plugin-redis
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: kt-qqbot-plugin-redis
template:
metadata:
labels:
app: kt-qqbot-plugin-redis
spec:
containers:
- name: redis
image: k3d-kt-registry.localhost:5000/redis:7.4-alpine
imagePullPolicy: IfNotPresent
args:
- redis-server
- --appendonly
- "no"
- --save
- ""
ports:
- name: redis
containerPort: 6379
readinessProbe:
tcpSocket:
port: 6379
initialDelaySeconds: 3
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 6
livenessProbe:
tcpSocket:
port: 6379
initialDelaySeconds: 15
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3
resources:
requests:
cpu: 25m
memory: 64Mi
limits:
cpu: 250m
memory: 256Mi
volumeMounts:
- name: redis-data
mountPath: /data
volumes:
- name: redis-data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: kt-napcat-webui-gateway
namespace: kt-prod
labels:
app: kt-napcat-webui-gateway
spec:
type: NodePort
selector:
app: kt-napcat-webui-gateway
ports:
- name: http
port: 48086
targetPort: 48086
nodePort: 30086
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kt-napcat-webui-gateway
namespace: kt-prod
labels:
app: kt-napcat-webui-gateway
spec:
replicas: 1
revisionHistoryLimit: 3
strategy:
type: Recreate
selector:
matchLabels:
app: kt-napcat-webui-gateway
template:
metadata:
labels:
app: kt-napcat-webui-gateway
spec:
containers:
- name: gateway
image: k3d-kt-registry.localhost:5000/kt-napcat-webui-gateway:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 48086
env:
- name: NODE_ENV
value: production
- name: TZ
value: Asia/Shanghai
- name: NAPCAT_WEBUI_GATEWAY_PORT
value: "48086"
- name: NAPCAT_WEBUI_GATEWAY_REDIS_HOST
value: kt-qqbot-plugin-redis
- name: NAPCAT_WEBUI_GATEWAY_REDIS_PORT
value: "6379"
- name: NAPCAT_WEBUI_GATEWAY_INTERNAL_SECRET
valueFrom:
secretKeyRef:
name: kt-template-online-api-env
key: NAPCAT_WEBUI_GATEWAY_INTERNAL_SECRET
readinessProbe:
tcpSocket:
port: 48086
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 6
livenessProbe:
tcpSocket:
port: 48086
initialDelaySeconds: 20
periodSeconds: 20
timeoutSeconds: 3
failureThreshold: 3
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 500m
memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
name: kt-qqbot-plugin-redis
namespace: kt-prod
labels:
app: kt-qqbot-plugin-redis
spec:
type: ClusterIP
selector:
app: kt-qqbot-plugin-redis
ports:
- name: redis
port: 6379
targetPort: 6379