deployment.yaml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: claude-code-hub
  5. namespace: {{NAMESPACE}}
  6. labels:
  7. app: claude-code-hub
  8. app.kubernetes.io/part-of: claude-code-hub
  9. spec:
  10. replicas: {{APP_REPLICAS}}
  11. revisionHistoryLimit: 5
  12. strategy:
  13. type: RollingUpdate
  14. rollingUpdate:
  15. maxSurge: 1
  16. maxUnavailable: 0
  17. selector:
  18. matchLabels:
  19. app: claude-code-hub
  20. template:
  21. metadata:
  22. labels:
  23. app: claude-code-hub
  24. spec:
  25. terminationGracePeriodSeconds: 660
  26. containers:
  27. - name: app
  28. image: {{APP_IMAGE}}
  29. imagePullPolicy: Always
  30. ports:
  31. - containerPort: 3000
  32. name: http
  33. env:
  34. - name: NODE_ENV
  35. value: production
  36. - name: DSN
  37. valueFrom:
  38. secretKeyRef:
  39. name: claude-code-hub-secrets
  40. key: dsn
  41. - name: REDIS_URL
  42. valueFrom:
  43. secretKeyRef:
  44. name: claude-code-hub-secrets
  45. key: redis-url
  46. - name: ADMIN_TOKEN
  47. valueFrom:
  48. secretKeyRef:
  49. name: claude-code-hub-secrets
  50. key: admin-token
  51. # instrumentation.ts 会先拿 PostgreSQL advisory lock,多副本首次启动时迁移会串行执行。
  52. - name: AUTO_MIGRATE
  53. value: "true"
  54. - name: DB_POOL_MAX
  55. value: "30"
  56. - name: DB_POOL_IDLE_TIMEOUT
  57. value: "20"
  58. - name: DB_POOL_CONNECT_TIMEOUT
  59. value: "10"
  60. - name: FETCH_CONNECT_TIMEOUT
  61. value: "30"
  62. - name: FETCH_HEADERS_TIMEOUT
  63. value: "600"
  64. - name: FETCH_BODY_TIMEOUT
  65. value: "600"
  66. - name: ENABLE_RATE_LIMIT
  67. value: "true"
  68. - name: ENABLE_API_KEY_REDIS_CACHE
  69. value: "true"
  70. - name: API_KEY_AUTH_CACHE_TTL_SECONDS
  71. value: "60"
  72. - name: ENABLE_API_KEY_VACUUM_FILTER
  73. value: "true"
  74. - name: ENABLE_PROVIDER_CACHE
  75. value: "true"
  76. - name: SESSION_TTL
  77. value: "300"
  78. - name: MESSAGE_REQUEST_WRITE_MODE
  79. value: "async"
  80. - name: MESSAGE_REQUEST_ASYNC_FLUSH_INTERVAL_MS
  81. value: "250"
  82. - name: MESSAGE_REQUEST_ASYNC_BATCH_SIZE
  83. value: "200"
  84. - name: MAX_RETRY_ATTEMPTS_DEFAULT
  85. value: "2"
  86. - name: TZ
  87. value: {{TIMEZONE}}
  88. resources:
  89. requests:
  90. cpu: 500m
  91. memory: 512Mi
  92. limits:
  93. cpu: "4"
  94. memory: 4Gi
  95. livenessProbe:
  96. httpGet:
  97. path: /api/actions/health
  98. port: 3000
  99. initialDelaySeconds: 15
  100. periodSeconds: 15
  101. timeoutSeconds: 3
  102. failureThreshold: 3
  103. readinessProbe:
  104. httpGet:
  105. path: /api/actions/health
  106. port: 3000
  107. initialDelaySeconds: 5
  108. periodSeconds: 5
  109. timeoutSeconds: 3
  110. failureThreshold: 2
  111. startupProbe:
  112. httpGet:
  113. path: /api/actions/health
  114. port: 3000
  115. initialDelaySeconds: 5
  116. periodSeconds: 5
  117. timeoutSeconds: 5
  118. failureThreshold: 24
  119. lifecycle:
  120. preStop:
  121. exec:
  122. command:
  123. - /bin/sh
  124. - -c
  125. - sleep 15
  126. securityContext:
  127. allowPrivilegeEscalation: false
  128. capabilities:
  129. drop:
  130. - ALL