From ddc2487d4ee25872e015395d0e075e09c93749ac Mon Sep 17 00:00:00 2001 From: naveenkumarsp Date: Thu, 9 Jul 2026 09:16:25 +0530 Subject: [PATCH] feat: add additionalInitContainers support to Qdrant StatefulSet The chart currently has no hook for injecting custom init containers. Init containers run sequentially to completion before the main Qdrant container starts, which is the correct place for one-shot node-level setup (e.g. raising vm.max_map_count before Qdrant loads collections). Without this, operators must either: - Add a privileged sidecar that runs sysctl alongside Qdrant (no strict ordering guarantee, container must sleep forever to stay alive), or - Deploy a separate DaemonSet tied to specific node pool labels. Changes: - templates/statefulset.yaml: append .Values.additionalInitContainers after the existing ensure-dir-ownership init container block. - values.yaml: add additionalInitContainers: [] with a fully commented real-world example (vm.max_map_count) and guidance on when to prefer init containers over sidecarContainers. --- charts/qdrant/templates/statefulset.yaml | 3 +++ charts/qdrant/values.yaml | 32 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/charts/qdrant/templates/statefulset.yaml b/charts/qdrant/templates/statefulset.yaml index 979ad12..76c5087 100644 --- a/charts/qdrant/templates/statefulset.yaml +++ b/charts/qdrant/templates/statefulset.yaml @@ -84,6 +84,9 @@ spec: {{- end }} {{- end }} {{- end }} + {{- if .Values.additionalInitContainers }} + {{- toYaml .Values.additionalInitContainers | trim | nindent 8 }} + {{- end }} containers: {{- if .Values.sidecarContainers -}} {{- toYaml .Values.sidecarContainers | trim | nindent 8 }} diff --git a/charts/qdrant/values.yaml b/charts/qdrant/values.yaml index 56e855d..f9034fa 100644 --- a/charts/qdrant/values.yaml +++ b/charts/qdrant/values.yaml @@ -188,6 +188,38 @@ config: service: enable_tls: false +# additionalInitContainers allows injecting extra init containers into the Qdrant pod. +# Init containers run to completion sequentially before the main Qdrant container starts, +# making them the correct place for node-level setup that must be done before Qdrant loads +# its collections (e.g. raising vm.max_map_count so mmap-heavy workloads do not hit +# ENOMEM when the number of virtual memory areas exceeds the kernel default of 65530). +# +# The chart already provides an 'ensure-dir-ownership' init container; entries defined +# here are appended after it. +# +# Example — raise vm.max_map_count on the host node so Qdrant can mmap many shards: +# +# additionalInitContainers: +# - name: set-vm-max-map-count +# # busybox is sufficient; any image with sysctl works. +# image: busybox +# # sysctl writes to the host kernel parameter because the container shares the +# # host kernel namespace when privileged: true. The value 262144 is Qdrant's +# # documented recommendation for production deployments with many collections. +# command: ['sysctl', '-w', 'vm.max_map_count=262144'] +# securityContext: +# privileged: true +# resources: +# requests: +# cpu: 1m +# memory: 1Mi +# +# When to use this instead of sidecarContainers: +# - The action must complete *before* Qdrant starts (strict ordering guarantee). +# - The action is a one-shot setup step with no ongoing process needed afterwards. +# - You want the pod to fail fast if setup fails (init container failure blocks the pod). +additionalInitContainers: [] + sidecarContainers: [] # sidecarContainers: # - name: my-sidecar