diff --git a/.changeset/waitformongodb-resources.md b/.changeset/waitformongodb-resources.md new file mode 100644 index 00000000..578cc906 --- /dev/null +++ b/.changeset/waitformongodb-resources.md @@ -0,0 +1,5 @@ +--- +"helm-charts": minor +--- + +Allow resources to be specified for the wait-for-mongodb init container via `hyperdx.deployment.waitForMongodb.resources` (empty by default). Required in clusters that enforce namespace resource quotas, where containers without requests/limits are rejected. Also documents how to set MongoDB container resources through the MongoDBCommunity `statefulSet` spec override. Ports ClickHouse/ClickStack-helm-charts#187 to the current chart layout. diff --git a/charts/clickstack/templates/hyperdx/deployment.yaml b/charts/clickstack/templates/hyperdx/deployment.yaml index 9d429d95..d20bf743 100644 --- a/charts/clickstack/templates/hyperdx/deployment.yaml +++ b/charts/clickstack/templates/hyperdx/deployment.yaml @@ -71,6 +71,10 @@ spec: securityContext: {{- toYaml . | nindent 12 }} {{- end }} + {{- with .Values.hyperdx.deployment.waitForMongodb.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} command: ['sh', '-c', 'until nc -z {{ include "clickstack.mongodb.svc" . }} 27017; do echo waiting for mongodb; sleep 2; done;'] {{- end }} {{- with .Values.hyperdx.deployment.initContainers }} diff --git a/charts/clickstack/tests/hyperdx-deployment_test.yaml b/charts/clickstack/tests/hyperdx-deployment_test.yaml index 242e3fc7..8e7fa4c1 100644 --- a/charts/clickstack/tests/hyperdx-deployment_test.yaml +++ b/charts/clickstack/tests/hyperdx-deployment_test.yaml @@ -241,6 +241,42 @@ tests: path: spec.template.spec.initContainers[0].imagePullPolicy value: Always + - it: should not set resources on the wait-for-mongodb initContainer by default + set: + mongodb: + enabled: true + asserts: + - isNull: + path: spec.template.spec.initContainers[0].resources + + - it: should render resources on the wait-for-mongodb initContainer when set + set: + mongodb: + enabled: true + hyperdx: + deployment: + waitForMongodb: + resources: + requests: + memory: 100Mi + cpu: 100m + limits: + memory: 200Mi + cpu: 500m + asserts: + - equal: + path: spec.template.spec.initContainers[0].resources.requests.memory + value: 100Mi + - equal: + path: spec.template.spec.initContainers[0].resources.requests.cpu + value: 100m + - equal: + path: spec.template.spec.initContainers[0].resources.limits.memory + value: 200Mi + - equal: + path: spec.template.spec.initContainers[0].resources.limits.cpu + value: 500m + - it: should not include initContainers when mongodb is disabled and no user init containers are provided set: mongodb: diff --git a/charts/clickstack/values.yaml b/charts/clickstack/values.yaml index 3de94821..5ca89dcf 100644 --- a/charts/clickstack/values.yaml +++ b/charts/clickstack/values.yaml @@ -144,6 +144,16 @@ hyperdx: waitForMongodb: image: "busybox@sha256:1fcf5df59121b92d61e066df1788e8df0cc35623f5d62d9679a41e163b6a0cdb" pullPolicy: IfNotPresent + # Resources for the wait-for-mongodb init container. Useful in clusters + # that enforce namespace resource quotas. + resources: {} + # Example: + # requests: + # memory: "100Mi" + # cpu: "100m" + # limits: + # memory: "200Mi" + # cpu: "500m" # Default connections and sources (ENABLED BY DEFAULT) # Set to empty string to disable: defaultConnections: "" or defaultSources: "" # To use an existing secret, set useExistingConfigSecret: true @@ -334,6 +344,16 @@ mongodb: # Full MongoDBCommunity CRD spec -- rendered verbatim into the CR. # See https://github.com/mongodb/mongodb-kubernetes/tree/master/docs/mongodbcommunity # for all available fields. Add persistence, nodeSelector, tolerations, etc. here. + # Container resources can be set via the operator's statefulset override, e.g.: + # statefulSet: + # spec: + # template: + # spec: + # containers: + # - name: mongod + # resources: + # requests: { memory: "512Mi", cpu: "500m" } + # limits: { memory: "2Gi", cpu: "2" } spec: members: 1 type: ReplicaSet