opensearch-k8s-operator: [BUG] Opensearch operator does not properly append the opensearch.yml file when general.additionalConfig is specified

What is the bug?

When you specify key pairs to general.additionalConfig, the operator adds those to the env instead of the opensearch.yml file. This is not the case when specifying dashboard.additionalConfig. In the Dashboard case, the additional values are appended to the dashboard config file.

How can one reproduce the bug?

  1. Specify general.additionalConfig and dashboard.additionalConfig in OpensearchCluster manifest and deploy the cluster.
general:
    additionalConfig:
      s3.client.default.endpoint: "s3.test.svc.cluster.local:9020"
      s3.client.default.protocol: "https"
      s3.client.default.max_retries: "3"
      s3.client.default.path_style_access: "false"
      s3.client.default.read_timeout: "50s"
      s3.client.default.use_throttle_retries: "true"
dashboard:
    additionalConfig:
      logging.verbose: "true"
      opensearch.requestHeadersWhitelist: |
        ["authorization", "securitytenant"]
      opensearch_security.auth.type: |
        ["basicauth", "openid"]
      opensearch_security.auth.multiple_auth_enabled: "true"
      opensearch_security.multitenancy.enabled: "true"
      opensearch_security.multitenancy.tenants.preferred: |
        [ "Private", "Global" ]
      opensearch_security.readonly_mode.roles: |
        ["kibana_read_only"]
  1. Check config map for opensearch cluster vs dashboard:
kubectl get cm opensearch-cluster-config -n opensearch -o yaml
apiVersion: v1
data:
  opensearch.yml: |
    plugins.security.audit.type: internal_opensearch
    plugins.security.authcz.admin_dn: ["CN=admin,OU=opensearch-cluster"]
    plugins.security.check_snapshot_restore_write_privileges: true
    plugins.security.enable_snapshot_restore_privilege: true
    plugins.security.nodes_dn: ["CN=opensearch-cluster,OU=opensearch-cluster"]
    plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"]
    plugins.security.ssl.http.enabled: true
    plugins.security.ssl.http.pemcert_filepath: tls-http/tls.crt
    plugins.security.ssl.http.pemkey_filepath: tls-http/tls.key
    plugins.security.ssl.http.pemtrustedcas_filepath: tls-http/ca.crt
    plugins.security.ssl.transport.enforce_hostname_verification: false
    plugins.security.ssl.transport.pemcert_filepath: tls-transport/tls.crt
    plugins.security.ssl.transport.pemkey_filepath: tls-transport/tls.key
    plugins.security.ssl.transport.pemtrustedcas_filepath: tls-transport/ca.crt
    plugins.security.system_indices.enabled: true
    plugins.security.system_indices.indices: [".opendistro-alerting-config",".opendistro-alerting-alert*",".opendistro-anomaly-results*",".opendistro-anomaly-detector*",".opendistro-anomaly-checkpoints",".opendistro-anomaly-detection-state",".opendistro-reports-*",".opendistro-notifications-*",".opendistro-notebooks",".opensearch-observability",".opendistro-asynchronous-search-response*",".replication-metadata-store"]
kind: ConfigMap
kubectl get cm opensearch-cluster-dashboards-config -n opensearch -o yaml
apiVersion: v1
data:
  opensearch_dashboards.yml: |
    logging.verbose: true
    opensearch.requestHeadersWhitelist: ["authorization", "securitytenant"]

    opensearch.ssl.verificationMode: none
    opensearch_security.auth.multiple_auth_enabled: true
    opensearch_security.auth.type: ["basicauth", "openid"]
    opensearch_security.multitenancy.enabled: true
    opensearch_security.multitenancy.tenants.enable_global: true
    opensearch_security.multitenancy.tenants.enable_private: true
    opensearch_security.multitenancy.tenants.preferred: [ "Private", "Global" ]
    opensearch_security.readonly_mode.roles: ["kibana_read_only"]

    server.name: opensearch-cluster-dashboards
kind: ConfigMap
  1. Check env vars of opensearch cluster vs dashboard:
kubectl describe sts opensearch-cluster-masters | grep -v "<none>" | grep Env -A 14
    Environment:
      cluster.initial_master_nodes:            opensearch-cluster-bootstrap-0
      discovery.seed_hosts:                    opensearch-cluster-discovery
      cluster.name:                            opensearch-cluster
      network.bind_host:                       0.0.0.0
      network.publish_host:                     (v1:metadata.name)
      OPENSEARCH_JAVA_OPTS:                    -Xmx1024M -Xms1024M -Dopensearch.transport.cname_in_publish_address=true
      node.roles:                              cluster_manager,data
      http.port:                               9200
      s3.client.default.endpoint:              s3.test.svc.cluster.local:9020
      s3.client.default.max_retries:           3
      s3.client.default.path_style_access:     false
      s3.client.default.protocol:              http
      s3.client.default.read_timeout:          50s
      s3.client.default.use_throttle_retries:  true
❯ kubectl describe deployment opensearch-cluster-dashboards | grep -v "<none>" | grep Env -A 5
   Environment:
     OPENSEARCH_HOSTS:     https://opensearch-cluster.opensearch.svc.cluster.local:9200
     SERVER_HOST:          0.0.0.0
     OPENSEARCH_USERNAME:  <set to the key 'username' in secret 'admin-credentials-secret'>  Optional: false
     OPENSEARCH_PASSWORD:  <set to the key 'password' in secret 'admin-credentials-secret'>  Optional: false

What is the expected behavior?

Expected behavior is that when you specify additionalConfig, those key/values need to get appended to the config-map as it is the case with the dashboard. Then after that, the opensearch.yml file in the pod will get updated with those new values. However, what happens is that those values get added to the Environment variables instead while the config-map remains unchanged. Hence, the opensearch.yml file does not get updated as expected.

What is your host/environment?

Kubernetes Version: 1.29.9 Kubernetes Node OS: Alma Linux 8

❯ helm ls -n opensearch-operator
NAME               	NAMESPACE          	REVISION	UPDATED                             	STATUS  	CHART                    	APP VERSION
opensearch-operator	opensearch-operator	5       	2024-12-21 20:41:06.619698 -0800 PST	deployed	opensearch-operator-2.7.0	2.7.0


❯ helm ls -n opensearch
NAME                       	NAMESPACE 	REVISION	UPDATED                             	STATUS  	CHART                   	APP VERSION
opensearch-cluster         	opensearch	22      	2024-12-21 19:13:04.555023 -0800 PST	deployed	opensearch-cluster-2.7.0	2.7.0

opensearchCluster general.version: 2.14.0 general.image: opensearchproject/opensearch:2.18.0

dashboard.version: 2.14.0 dashboard.image: opensearchproject/opensearch-dashboards:2.18.0 initHelper.image: busybox:latest

Do you have any screenshots?

n/a

Do you have any additional context?

I am trying to add S3 related configuration to the opensearch.yml file via general.additionalConfig section of OpenSearchCluster manifest.

About this issue

Most upvoted comments

Hi @swoehrl-mw !

I have not found a way to configure the audit log to write to Stdout (debug). I need to be able to dump the audit log so that it can be stored in a tamper-proof manner.