You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
13 KiB

11 months ago
  1. ---
  2. apiVersion: v1
  3. kind: PersistentVolume
  4. metadata:
  5. name: anything-llm-volume
  6. annotations:
  7. pv.beta.kubernetes.io/uid: "1000"
  8. pv.beta.kubernetes.io/gid: "1000"
  9. spec:
  10. storageClassName: gp2
  11. capacity:
  12. storage: 5Gi
  13. accessModes:
  14. - ReadWriteOnce
  15. awsElasticBlockStore:
  16. # This is the volume UUID from AWS EC2 EBS Volumes list.
  17. volumeID: "{{ anythingllm_awsElasticBlockStore_volumeID }}"
  18. fsType: ext4
  19. nodeAffinity:
  20. required:
  21. nodeSelectorTerms:
  22. - matchExpressions:
  23. - key: topology.kubernetes.io/zone
  24. operator: In
  25. values:
  26. - us-east-1c
  27. ---
  28. apiVersion: v1
  29. kind: PersistentVolumeClaim
  30. metadata:
  31. name: anything-llm-volume-claim
  32. namespace: "{{ namespace }}"
  33. spec:
  34. accessModes:
  35. - ReadWriteOnce
  36. resources:
  37. requests:
  38. storage: 5Gi
  39. ---
  40. apiVersion: apps/v1
  41. kind: Deployment
  42. metadata:
  43. name: anything-llm
  44. namespace: "{{ namespace }}"
  45. labels:
  46. anything-llm: "true"
  47. spec:
  48. selector:
  49. matchLabels:
  50. k8s-app: anything-llm
  51. replicas: 1
  52. strategy:
  53. type: RollingUpdate
  54. rollingUpdate:
  55. maxSurge: 0%
  56. maxUnavailable: 100%
  57. template:
  58. metadata:
  59. labels:
  60. anything-llm: "true"
  61. k8s-app: anything-llm
  62. app.kubernetes.io/name: anything-llm
  63. app.kubernetes.io/part-of: anything-llm
  64. annotations:
  65. prometheus.io/scrape: "true"
  66. prometheus.io/path: /metrics
  67. prometheus.io/port: "9090"
  68. spec:
  69. serviceAccountName: "default"
  70. terminationGracePeriodSeconds: 10
  71. securityContext:
  72. fsGroup: 1000
  73. runAsNonRoot: true
  74. runAsGroup: 1000
  75. runAsUser: 1000
  76. affinity:
  77. nodeAffinity:
  78. requiredDuringSchedulingIgnoredDuringExecution:
  79. nodeSelectorTerms:
  80. - matchExpressions:
  81. - key: topology.kubernetes.io/zone
  82. operator: In
  83. values:
  84. - us-east-1c
  85. containers:
  86. - name: anything-llm
  87. resources:
  88. limits:
  89. memory: "1Gi"
  90. cpu: "500m"
  91. requests:
  92. memory: "512Mi"
  93. cpu: "250m"
  94. imagePullPolicy: IfNotPresent
  95. image: "mintplexlabs/anythingllm:render"
  96. securityContext:
  97. allowPrivilegeEscalation: true
  98. capabilities:
  99. add:
  100. - SYS_ADMIN
  101. runAsNonRoot: true
  102. runAsGroup: 1000
  103. runAsUser: 1000
  104. command:
  105. # Specify a command to override the Dockerfile's ENTRYPOINT.
  106. - /bin/bash
  107. - -c
  108. - |
  109. set -x -e
  110. sleep 3
  111. echo "AWS_REGION: $AWS_REGION"
  112. echo "SERVER_PORT: $SERVER_PORT"
  113. echo "NODE_ENV: $NODE_ENV"
  114. echo "STORAGE_DIR: $STORAGE_DIR"
  115. {
  116. cd /app/server/ &&
  117. npx prisma generate --schema=./prisma/schema.prisma &&
  118. npx prisma migrate deploy --schema=./prisma/schema.prisma &&
  119. node /app/server/index.js
  120. echo "Server process exited with status $?"
  121. } &
  122. {
  123. node /app/collector/index.js
  124. echo "Collector process exited with status $?"
  125. } &
  126. wait -n
  127. exit $?
  128. readinessProbe:
  129. httpGet:
  130. path: /v1/api/health
  131. port: 8888
  132. initialDelaySeconds: 15
  133. periodSeconds: 5
  134. successThreshold: 2
  135. livenessProbe:
  136. httpGet:
  137. path: /v1/api/health
  138. port: 8888
  139. initialDelaySeconds: 15
  140. periodSeconds: 5
  141. failureThreshold: 3
  142. env:
  143. - name: AWS_REGION
  144. value: "{{ aws_region }}"
  145. - name: AWS_ACCESS_KEY_ID
  146. value: "{{ aws_access_id }}"
  147. - name: AWS_SECRET_ACCESS_KEY
  148. value: "{{ aws_access_secret }}"
  149. - name: SERVER_PORT
  150. value: "3001"
  151. - name: JWT_SECRET
  152. value: "my-random-string-for-seeding" # Please generate random string at least 12 chars long.
  153. - name: STORAGE_DIR
  154. value: "/storage"
  155. - name: NODE_ENV
  156. value: "production"
  157. - name: UID
  158. value: "1000"
  159. - name: GID
  160. value: "1000"
  161. volumeMounts:
  162. - name: anything-llm-server-storage-volume-mount
  163. mountPath: /storage
  164. volumes:
  165. - name: anything-llm-server-storage-volume-mount
  166. persistentVolumeClaim:
  167. claimName: anything-llm-volume-claim
  168. ---
  169. # This serves the UI and the backend.
  170. apiVersion: networking.k8s.io/v1
  171. kind: Ingress
  172. metadata:
  173. name: anything-llm-ingress
  174. namespace: "{{ namespace }}"
  175. annotations:
  176. external-dns.alpha.kubernetes.io/hostname: "{{ namespace }}-chat.{{ base_domain }}"
  177. kubernetes.io/ingress.class: "internal-ingress"
  178. nginx.ingress.kubernetes.io/rewrite-target: /
  179. ingress.kubernetes.io/ssl-redirect: "false"
  180. spec:
  181. rules:
  182. - host: "{{ namespace }}-chat.{{ base_domain }}"
  183. http:
  184. paths:
  185. - path: /
  186. pathType: Prefix
  187. backend:
  188. service:
  189. name: anything-llm-svc
  190. port:
  191. number: 3001
  192. tls: # < placing a host in the TLS config will indicate a cert should be created
  193. - hosts:
  194. - "{{ namespace }}-chat.{{ base_domain }}"
  195. secretName: letsencrypt-prod
  196. ---
  197. apiVersion: v1
  198. kind: Service
  199. metadata:
  200. labels:
  201. kubernetes.io/name: anything-llm
  202. name: anything-llm-svc
  203. namespace: "{{ namespace }}"
  204. spec:
  205. ports:
  206. # "port" is external port, and "targetPort" is internal.
  207. - port: 3301
  208. targetPort: 3001
  209. name: traffic
  210. - port: 9090
  211. targetPort: 9090
  212. name: metrics
  213. selector:
  214. k8s-app: anything-llm