From 9b2c23b0c875a6d12a15f17141d4abe63838bf3d Mon Sep 17 00:00:00 2001
From: Guilherme Oki <okiserra@gmail.com>
Date: Tue, 13 Aug 2024 10:21:21 -0300
Subject: [PATCH] feat(helm): add option to set resources for initHelper (#865)

### Description

This PR adds an option to define resources for initHelper container.

### Issues Resolved

Closes this issue
https://github.com/opensearch-project/opensearch-k8s-operator/issues/866

### Check List
- [X] Commits are signed per the DCO using --signoff
- [X] Unittest added for the new/changed functionality and all unit
tests are successful
- [X] Customer-visible features documented
- [X] No linter warnings (`make lint`)

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Guilherme Oki <oki.guilherme@gmail.com>
---
 .../templates/opensearch-cluster-cr.yaml              |  4 ++++
 charts/opensearch-cluster/values.yaml                 | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/charts/opensearch-cluster/templates/opensearch-cluster-cr.yaml b/charts/opensearch-cluster/templates/opensearch-cluster-cr.yaml
index e08132ca..79f3b70b 100644
--- a/charts/opensearch-cluster/templates/opensearch-cluster-cr.yaml
+++ b/charts/opensearch-cluster/templates/opensearch-cluster-cr.yaml
@@ -27,6 +27,10 @@ spec:
     imagePullSecrets:
       {{ toYaml .Values.opensearchCluster.initHelper.imagePullSecrets | nindent 6 }}
     {{- end }}
+    {{- if .Values.opensearchCluster.initHelper.resources }}
+    resources:
+      {{- toYaml .Values.opensearchCluster.initHelper.resources | nindent 6 }}
+    {{- end }}
   {{- end }}
   general:
     {{- if .Values.opensearchCluster.general.version }}
diff --git a/charts/opensearch-cluster/values.yaml b/charts/opensearch-cluster/values.yaml
index c0cc622f..2841ea81 100644
--- a/charts/opensearch-cluster/values.yaml
+++ b/charts/opensearch-cluster/values.yaml
@@ -27,6 +27,17 @@ opensearchCluster:
       limits:
         memory: "1Gi"
         cpu: "500m"
+  initHelper:
+    imagePullSecrets: []
+    # - registryKeySecretName
+    imagePullPolicy: IfNotPresent
+    resources: {}
+    # requests:
+    #   memory: "1Gi"
+    #   cpu: "500m"
+    # limits:
+    #   memory: "1Gi"
+    #   cpu: "500m"
   nodePools:
     - component: masters
       diskSize: "30Gi"