Skip to content

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Apr 20, 2025

Description

This PR seeks to build a way to overwrite the default security plugin settings from here. I'm not able to overwrite this settings by adding plugins.security.audit.type: log4j to spec.general.additionalConfig. I can confirm that these changes produce the desired output by looking at the output being printed here.

I think we should also consider adding plugins.security.allow_default_init_securityindex: true to the default security config values because this explicitly tells OpenSearch to init the security index from any suppled yaml files.

Issues Resolved

Resolves #736

Check List

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

If CRDs are changed:

  • CRD YAMLs updated (make manifests) and also copied into the helm chart
  • Changes to CRDs documented

Please refer to the PR guidelines before submitting this pull request.

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.

@cwperks cwperks changed the title Add additionalConfig settings to overwrite default security plugin settings Allow additionalConfig settings to overwrite default security plugin settings Apr 20, 2025
@cwperks cwperks marked this pull request as ready for review April 20, 2025 01:39
r.reconcilerContext.AddConfig("plugins.security.system_indices.enabled", "true")
r.reconcilerContext.AddConfig("plugins.security.system_indices.indices", string(systemIndices))

if len(r.instance.Spec.General.AdditionalConfig) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cwperks even with this change, if we have to add the plugins.security.audit.type with additionalConfig will it create 2 values of plugins.security.audit.type ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it better to add it under spec.security?

spec:
  security:
       auditType: "log4j"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding @swoehrl-mw

Copy link
Member Author

@cwperks cwperks Apr 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it won't create 2 values. It will overwrite the default and log that out accordingly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cwperks can should be able to get this in #1011, can you update the readme with some details https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/userguide/main.md.
Thanks
@getsaurabh02

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies for not addressing this earlier, pushing a commit in a few min

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added documentation

Copy link
Contributor

@josedev-union josedev-union left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR correctly fixes the usage of spec.general.additionalConfig.
additionalConfig is meant to be added to opensearch.yml, but untill now it's been incorrectly used as extra environment variables.

// Append additional config to env vars, use General.AdditionalConfig by default, overwrite with Bootstrap.AdditionalConfig
extraConfig := cr.Spec.General.AdditionalConfig
if cr.Spec.Bootstrap.AdditionalConfig != nil {
extraConfig = cr.Spec.Bootstrap.AdditionalConfig
}
keys := helpers.SortedKeys(extraConfig)
for _, k := range keys {
env = append(env, corev1.EnvVar{
Name: k,
Value: extraConfig[k],
})
}

extraConfig := helpers.MergeConfigs(r.instance.Spec.General.AdditionalConfig, nodePool.AdditionalConfig)
sts := builders.NewSTSForNodePool(
username,
r.instance,
nodePool,
nodePoolConfig.ConfigHash,
r.reconcilerContext.Volumes,
r.reconcilerContext.VolumeMounts,
extraConfig,
)

// Append additional config to env vars
keys := helpers.SortedKeys(extraConfig)
for _, k := range keys {
sts.Spec.Template.Spec.Containers[0].Env = append(sts.Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{
Name: k,
Value: extraConfig[k],
})
}

Can you remove the parts that generate those extra env vars?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing: could you add unit tests for this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In Review

Development

Successfully merging this pull request may close these issues.

[BUG] There is no way to configure some security plugin settings

3 participants