Skip to content

Conversation

patelsmit32123
Copy link
Contributor

Issues Resolved

Fixes #1108

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.

@patelsmit32123 patelsmit32123 changed the title Use container/pod security context user/group as owner for /usr/share… Use container/pod security context user/group as owner for /usr/share/opensearch/data directory Sep 26, 2025
…/opensearch/data directory

Signed-off-by: patelsmit32123 <[email protected]>
@patelsmit32123 patelsmit32123 changed the title Use container/pod security context user/group as owner for /usr/share/opensearch/data directory Use container/pod securityContext user/group as owner for /usr/share/opensearch/data directory Sep 26, 2025
ImagePullPolicy: initHelperImage.GetImagePullPolicy(),
Resources: resources,
Command: []string{"sh", "-c"},
Args: []string{"chown -R 1000:1000 /usr/share/opensearch/data"},
Copy link
Member

Choose a reason for hiding this comment

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

@prudhvigodithi
Copy link
Member

This is a good change. LGTM

}

// ResolveUidGid resolves the UID and GID using security context hierarchy
// Priority: securityContext.runAsUser/Group > podSecurityContext.runAsUser/Group > defaults (1000:1000)
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add this to the repo and helm charts readme https://github.com/opensearch-project/opensearch-k8s-operator/blob/main/docs/userguide/main.md ?

Copy link

Choose a reason for hiding this comment

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

Does the operator really need to know about UID & GID?

If the securityContext "fsGroup: 1000" would be set, the PVC is chowned on volume mount.

Docs:
fsGroup: A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows.

@prudhvigodithi
Copy link
Member

prudhvigodithi commented Oct 4, 2025

@patelsmit32123 you can create a separate PR for this comment #1109 (comment).

@prudhvigodithi prudhvigodithi merged commit ff376b2 into opensearch-project:main Oct 4, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in Engineering Effectiveness Board Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[BUG] Init containers creating /usr/share/opensearch/data directory with static 1000 UID:GID user

3 participants