Feature/helm separate workers (#4679)

* add test

* try breaking out background workers

* fix helm lint complaints

* rename disabled files more

* try different folder structure

* fix beat selector

* vespa setup should break on success

* improved instructions for basic helm chart testing

---------

Co-authored-by: Richard Kuo (Onyx) <rkuo@onyx.app>
This commit is contained in:
rkuo-danswer
2025-05-12 19:23:32 -07:00
committed by GitHub
parent d91f776c2d
commit d8068f0a68
11 changed files with 622 additions and 44 deletions

View File

@@ -1,13 +1,21 @@
# Local testing
- One time setup
- brew install kind
- Ensure you have no config at ~/.kube/config
- kind create cluster
- mv ~/.kube/config ~/.kube/kind-config
## One time setup
* brew install kind
* Ensure you have no config at ~/.kube/config
* kind create cluster
* mv ~/.kube/config ~/.kube/kind-config
- Command setup
- export KUBECONFIG=~/.kube/kind-config
- kubectl config use-context kind-kind
- from source root run
- ct install --all --helm-extra-set-args="--set=nginx.enabled=false" --debug --config ct.yaml
## Automated install and test with ct
* export KUBECONFIG=~/.kube/kind-config
* kubectl config use-context kind-kind
* from source root run the following. This does a very basic test against the web server
* ct install --all --helm-extra-set-args="--set=nginx.enabled=false" --debug --config ct.yaml
## Test the entire cluster manually
* helm install onyx . -n onyx --set postgresql.primary.persistence.enabled=false
* the postgres flag is to keep the storage ephemeral for testing, you probably don't want to set that in prod
* kubectl -n onyx port-forward service/onyx-nginx 8080:80
* this will forward the local port 8080 to the installed chart for you to run tests, etc.
* When you are finished
* helm uninstall onyx -n onyx

View File

@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "onyx-stack.fullname" . }}-celery-beat
labels:
{{- include "onyx-stack.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "onyx-stack.selectorLabels" . | nindent 6 }}
{{- if .Values.celery_beat.deploymentLabels }}
{{- toYaml .Values.celery_beat.deploymentLabels | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.celery_beat.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "onyx-stack.labels" . | nindent 8 }}
{{- with .Values.celery_beat.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_beat.podSecurityContext | nindent 8 }}
containers:
- name: celery-beat
securityContext:
{{- toYaml .Values.celery_beat.securityContext | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.celery_shared.image.pullPolicy }}
command:
[
"celery",
"-A",
"onyx.background.celery.versioned_apps.beat",
"beat",
"--loglevel=INFO",
]
resources:
{{- toYaml .Values.celery_beat.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.envConfigMapName }}
env:
{{- include "onyx-stack.envSecrets" . | nindent 12}}

View File

@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "onyx-stack.fullname" . }}-celery-worker-heavy
labels:
{{- include "onyx-stack.labels" . | nindent 4 }}
spec:
{{- if not .Values.celery_worker_heavy.autoscaling.enabled }}
replicas: {{ .Values.celery_worker_heavy.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "onyx-stack.selectorLabels" . | nindent 6 }}
{{- if .Values.celery_worker_heavy.deploymentLabels }}
{{- toYaml .Values.celery_worker_heavy.deploymentLabels | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.celery_worker_heavy.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "onyx-stack.labels" . | nindent 8 }}
{{- with .Values.celery_worker_heavy.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_heavy.podSecurityContext | nindent 8 }}
containers:
- name: celery-worker-heavy
securityContext:
{{- toYaml .Values.celery_worker_heavy.securityContext | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.celery_shared.image.pullPolicy }}
command:
[
"celery",
"-A",
"onyx.background.celery.versioned_apps.heavy",
"worker",
"--loglevel=INFO",
"--hostname=heavy@%n",
"-Q",
"connector_pruning,connector_doc_permissions_sync,connector_external_group_sync,csv_generation",
]
resources:
{{- toYaml .Values.celery_worker_heavy.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.envConfigMapName }}
env:
{{- include "onyx-stack.envSecrets" . | nindent 12}}

View File

@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "onyx-stack.fullname" . }}-celery-worker-indexing
labels:
{{- include "onyx-stack.labels" . | nindent 4 }}
spec:
{{- if not .Values.celery_worker_indexing.autoscaling.enabled }}
replicas: {{ .Values.celery_worker_indexing.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "onyx-stack.selectorLabels" . | nindent 6 }}
{{- if .Values.celery_worker_indexing.deploymentLabels }}
{{- toYaml .Values.celery_worker_indexing.deploymentLabels | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.celery_worker_indexing.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "onyx-stack.labels" . | nindent 8 }}
{{- with .Values.celery_worker_indexing.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_indexing.podSecurityContext | nindent 8 }}
containers:
- name: celery-worker-indexing
securityContext:
{{- toYaml .Values.celery_worker_indexing.securityContext | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.celery_shared.image.pullPolicy }}
command:
[
"celery",
"-A",
"onyx.background.celery.versioned_apps.indexing",
"worker",
"--loglevel=INFO",
"--hostname=indexing@%n",
"-Q",
"connector_indexing",
]
resources:
{{- toYaml .Values.celery_worker_indexing.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.envConfigMapName }}
env:
- name: ENABLE_MULTIPASS_INDEXING
value: "{{ .Values.celery_worker_indexing.enableMiniChunk }}"
{{- include "onyx-stack.envSecrets" . | nindent 12}}

View File

@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "onyx-stack.fullname" . }}-celery-worker-light
labels:
{{- include "onyx-stack.labels" . | nindent 4 }}
spec:
{{- if not .Values.celery_worker_light.autoscaling.enabled }}
replicas: {{ .Values.celery_worker_light.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "onyx-stack.selectorLabels" . | nindent 6 }}
{{- if .Values.celery_worker_light.deploymentLabels }}
{{- toYaml .Values.celery_worker_light.deploymentLabels | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.celery_worker_light.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "onyx-stack.labels" . | nindent 8 }}
{{- with .Values.celery_worker_light.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_light.podSecurityContext | nindent 8 }}
containers:
- name: celery-worker-light
securityContext:
{{- toYaml .Values.celery_worker_light.securityContext | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.celery_shared.image.pullPolicy }}
command:
[
"celery",
"-A",
"onyx.background.celery.versioned_apps.light",
"worker",
"--loglevel=INFO",
"--hostname=light@%n",
"-Q",
"vespa_metadata_sync,connector_deletion,doc_permissions_upsert,checkpoint_cleanup",
]
resources:
{{- toYaml .Values.celery_worker_light.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.envConfigMapName }}
env:
{{- include "onyx-stack.envSecrets" . | nindent 12}}

View File

@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "onyx-stack.fullname" . }}-celery-worker-monitoring
labels:
{{- include "onyx-stack.labels" . | nindent 4 }}
spec:
{{- if not .Values.celery_worker_monitoring.autoscaling.enabled }}
replicas: {{ .Values.celery_worker_monitoring.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "onyx-stack.selectorLabels" . | nindent 6 }}
{{- if .Values.celery_worker_monitoring.deploymentLabels }}
{{- toYaml .Values.celery_worker_monitoring.deploymentLabels | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.celery_worker_monitoring.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "onyx-stack.labels" . | nindent 8 }}
{{- with .Values.celery_worker_monitoring.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_monitoring.podSecurityContext | nindent 8 }}
containers:
- name: celery-worker-monitoring
securityContext:
{{- toYaml .Values.celery_worker_monitoring.securityContext | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.celery_shared.image.pullPolicy }}
command:
[
"celery",
"-A",
"onyx.background.celery.versioned_apps.monitoring",
"worker",
"--loglevel=INFO",
"--hostname=monitoring@%n",
"-Q",
"monitoring",
]
resources:
{{- toYaml .Values.celery_worker_monitoring.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.envConfigMapName }}
env:
{{- include "onyx-stack.envSecrets" . | nindent 12}}

View File

@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "onyx-stack.fullname" . }}-celery-worker-primary
labels:
{{- include "onyx-stack.labels" . | nindent 4 }}
spec:
{{- if not .Values.celery_worker_primary.autoscaling.enabled }}
replicas: {{ .Values.celery_worker_primary.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "onyx-stack.selectorLabels" . | nindent 6 }}
{{- if .Values.celery_worker_primary.deploymentLabels }}
{{- toYaml .Values.celery_worker_primary.deploymentLabels | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.celery_worker_primary.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "onyx-stack.labels" . | nindent 8 }}
{{- with .Values.celery_worker_primary.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_primary.podSecurityContext | nindent 8 }}
containers:
- name: celery-worker-primary
securityContext:
{{- toYaml .Values.celery_worker_primary.securityContext | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.celery_shared.image.pullPolicy }}
command:
[
"celery",
"-A",
"onyx.background.celery.versioned_apps.primary",
"worker",
"--loglevel=INFO",
"--hostname=primary@%n",
"-Q",
"celery,periodic_tasks",
]
resources:
{{- toYaml .Values.celery_worker_primary.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.envConfigMapName }}
env:
{{- include "onyx-stack.envSecrets" . | nindent 12}}

View File

@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "onyx-stack.fullname" . }}-celery-worker-user-files-indexing
labels:
{{- include "onyx-stack.labels" . | nindent 4 }}
spec:
{{- if not .Values.celery_worker_user_files_indexing.autoscaling.enabled }}
replicas: {{ .Values.celery_worker_user_files_indexing.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "onyx-stack.selectorLabels" . | nindent 6 }}
{{- if .Values.celery_worker_user_files_indexing.deploymentLabels }}
{{- toYaml .Values.celery_worker_user_files_indexing.deploymentLabels | nindent 6 }}
{{- end }}
template:
metadata:
{{- with .Values.celery_worker_user_files_indexing.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "onyx-stack.labels" . | nindent 8 }}
{{- with .Values.celery_worker_user_files_indexing.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "onyx-stack.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.celery_worker_user_files_indexing.podSecurityContext | nindent 8 }}
containers:
- name: celery-worker-user-files-indexing
securityContext:
{{- toYaml .Values.celery_worker_user_files_indexing.securityContext | nindent 12 }}
image: "{{ .Values.celery_shared.image.repository }}:{{ .Values.celery_shared.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.celery_shared.image.pullPolicy }}
command:
[
"celery",
"-A",
"onyx.background.celery.versioned_apps.indexing",
"worker",
"--loglevel=INFO",
"--hostname=user-files-indexing@%n",
"-Q",
"user_files_indexing",
]
resources:
{{- toYaml .Values.celery_worker_user_files_indexing.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ .Values.config.envConfigMapName }}
env:
{{- include "onyx-stack.envSecrets" . | nindent 12}}

View File

@@ -296,58 +296,218 @@ api:
nodeSelector: {}
tolerations: []
background:
replicaCount: 1
# background:
# replicaCount: 1
# autoscaling:
# enabled: false
# # minReplicas: 1
# # maxReplicas: 100
# # targetCPUUtilizationPercentage: 80
# # targetMemoryUtilizationPercentage: 80
#
# image:
# repository: onyxdotapp/onyx-backend
# pullPolicy: IfNotPresent
# # Overrides the image tag whose default is the chart appVersion.
# tag: ""
# podAnnotations: {}
# podLabels:
# scope: onyx-backend
# app: background
# deploymentLabels:
# app: background
# podSecurityContext:
# {}
# # fsGroup: 2000
# securityContext:
# privileged: true
# runAsUser: 0
# enableMiniChunk: "true"
# resources: {}
# # We usually recommend not to specify default resources and to leave this as a conscious
# # choice for the user. This also increases chances charts run on environments with little
# # resources, such as Minikube. If you do want to specify resources, uncomment the following
# # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# # requests:
# # cpu: 1000m # Requests 1 CPU core
# # memory: 1Gi # Requests 1 GiB of memory
# # limits:
# # cpu: 2000m # Limits to 2 CPU cores
# # memory: 2Gi # Limits to 2 GiB of memory
#
#
# # Additional volumes on the output Deployment definition.
# volumes: []
# # - name: foo
# # secret:
# # secretName: mysecret
# # optional: false
#
# # Additional volumeMounts on the output Deployment definition.
# volumeMounts: []
# # - name: foo
# # mountPath: "/etc/foo"
# # readOnly: true
#
# nodeSelector: {}
# tolerations: []
# affinity: {}
celery_shared:
image:
repository: onyxdotapp/onyx-backend
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
tag: "" # Overrides the image tag whose default is the chart appVersion.
celery_beat:
replicaCount: 1
podAnnotations: {}
podLabels:
scope: onyx-backend
app: background
scope: onyx-backend-celery
app: celery-beat
deploymentLabels:
app: background
app: celery-beat
podSecurityContext:
{}
# fsGroup: 2000
securityContext:
privileged: true
runAsUser: 0
enableMiniChunk: "true"
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# requests:
# cpu: 1000m # Requests 1 CPU core
# memory: 1Gi # Requests 1 GiB of memory
# limits:
# cpu: 2000m # Limits to 2 CPU cores
# memory: 2Gi # Limits to 2 GiB of memory
volumes: [] # Additional volumes on the output Deployment definition.
volumeMounts: [] # Additional volumeMounts on the output Deployment definition.
nodeSelector: {}
tolerations: []
affinity: {}
celery_worker_heavy:
replicaCount: 1
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
podAnnotations: {}
podLabels:
scope: onyx-backend-celery
app: celery-worker-heavy
deploymentLabels:
app: celery-worker-heavy
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources: {}
volumes: [] # Additional volumes on the output Deployment definition.
volumeMounts: [] # Additional volumeMounts on the output Deployment definition.
nodeSelector: {}
tolerations: []
affinity: {}
# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false
celery_worker_indexing:
replicaCount: 1
autoscaling:
enabled: false
podAnnotations: {}
podLabels:
scope: onyx-backend-celery
app: celery-worker-indexing
deploymentLabels:
app: celery-worker-indexing
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources: {}
volumes: [] # Additional volumes on the output Deployment definition.
volumeMounts: [] # Additional volumeMounts on the output Deployment definition.
nodeSelector: {}
tolerations: []
affinity: {}
# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true
celery_worker_light:
replicaCount: 1
autoscaling:
enabled: false
podAnnotations: {}
podLabels:
scope: onyx-backend-celery
app: celery-worker-light
deploymentLabels:
app: celery-worker-light
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources: {}
volumes: [] # Additional volumes on the output Deployment definition.
volumeMounts: [] # Additional volumeMounts on the output Deployment definition.
nodeSelector: {}
tolerations: []
affinity: {}
celery_worker_monitoring:
replicaCount: 1
autoscaling:
enabled: false
podAnnotations: {}
podLabels:
scope: onyx-backend-celery
app: celery-worker-monitoring
deploymentLabels:
app: celery-worker-monitoring
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources: {}
volumes: [] # Additional volumes on the output Deployment definition.
volumeMounts: [] # Additional volumeMounts on the output Deployment definition.
nodeSelector: {}
tolerations: []
affinity: {}
celery_worker_primary:
replicaCount: 1
autoscaling:
enabled: false
podAnnotations: {}
podLabels:
scope: onyx-backend-celery
app: celery-worker-primary
deploymentLabels:
app: celery-worker-primary
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources: {}
volumes: [] # Additional volumes on the output Deployment definition.
volumeMounts: [] # Additional volumeMounts on the output Deployment definition.
nodeSelector: {}
tolerations: []
affinity: {}
celery_worker_user_files_indexing:
replicaCount: 1
autoscaling:
enabled: false
podAnnotations: {}
podLabels:
scope: onyx-backend-celery
app: celery-worker-user-files-indexing
deploymentLabels:
app: celery-worker-user-files-indexing
podSecurityContext:
{}
securityContext:
privileged: true
runAsUser: 0
resources: {}
volumes: [] # Additional volumes on the output Deployment definition.
volumeMounts: [] # Additional volumeMounts on the output Deployment definition.
nodeSelector: {}
tolerations: []
affinity: {}