Run script after a helm installation

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
CHART APP VERSION
opensearch-2.8.0 2.4.0
opensearch-dashboards-2.6.0 2.4.0

Describe the issue:
I am installing opensearch using helm with values file in order to supply different security configuration files, i.e. openid authentication, roles etc…
After installation the following link state:

that we need to run securityadmin.sh script in order to initialize the .opendistro_security index.

I would like to run some scripts to create another index, some ISM policies in the cluster and securityadmin.sh after the helm installation completed and the pods are up.

I have seen in the helm values file the following commented:

extraContainers:
# - name: do-something
# image: busybox
# command: ['do', 'something']

I couldn’t find information about the ‘extraContainers’.
As I understand after the opensearch installation is done and the pods are up, the '‘busybox’ will run and execute the command.
I have run the helm using ‘extraContainers’ with some command, and it doesn’t seem to do that, I can’t see ‘busybox’ created.
Do you have any suggestion on how to execute commands on the nodes or using the opensearch-dashboards API after pods are up and running using HELM?

Thanks

Configuration:

Relevant Logs or Screenshots:

I have found a way to solve my problem, using the following section(lifecycle) in the values file.

lifecycle: 
  # preStop:
  #   exec:
  #     command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
  postStart:
    exec:
      command:
1 Like

thank you for the idea with lifecycle, I’v used it for keystore creation and setup