Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][helm chart of opensearch] init container for fsgroup-volume requires root #480

Open
patrickdung opened this issue Oct 7, 2023 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@patrickdung
Copy link

patrickdung commented Oct 7, 2023

Describe the bug
A clear and concise description of what the bug is.

The helm chart requires root, after the helm chart is deployed:

      initContainers:
      - args:
        - chown -R 1000:1000 /usr/share/opensearch/data
        command:
        - sh
        - -c
        image: busybox:latest
        imagePullPolicy: IfNotPresent
        name: fsgroup-volume
        resources: {}
        securityContext:
          runAsUser: 0
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /usr/share/opensearch/data
          name: opensearch-cluster-master

runAsUser: 0 is in securityContext.
This cause problem with some kubernetes environment which does not allow to run as root.
Like OpenShift platform. On openshift, the workaronud could be:
oc adm policy add-scc-to-user privileged -z default
But it requires cluster admin level privilege and may not be possible to run it as tenants.

To Reproduce
Steps to reproduce the behavior:
Deploy the default helm chart.

Expected behavior
Provide a method for users that cannot run the initcontainer as root (user 0).

Chart Name
Specify the Chart which is affected?
opensearch-2.15.0

Screenshots
If applicable, add screenshots to help explain your problem.

Similar to level=error msg="container_linux.go:367: starting container process caused: exec: \"./opensearch-docker-entrypoint.sh\": stat ./opensearch-docker-entrypoint.sh: permission denied"
opensearch-project/opensearch-devops#97

Host/Environment (please complete the following information):

  • Helm Version: v3.13.0
  • Kubernetes Version: k3s 1.27.6

Additional context
Add any other context about the problem here.

https://forum.opensearch.org/t/opensearch-failing-on-openshift-environment/13052/3
#384
opensearch-project/opensearch-build#3625

@patrickdung patrickdung added bug Something isn't working untriaged Issues that have not yet been triaged labels Oct 7, 2023
@prudhvigodithi prudhvigodithi added good first issue Good for newcomers and removed untriaged Issues that have not yet been triaged labels Oct 10, 2023
@felix185
Copy link

is there a workaround for k8s, too?
On the cluster I am working with there are policies that containers are not allowed to run with root users. Another policy is existing which forbids containers to be run as privileged.

@patrickdung
Copy link
Author

On a newer version of the helm chart (e.g. 2.21)

The default value should be like

podSecurityContext:
  fsGroup: 1000
  runAsUser: 1000

securityContext:
  capabilities:
    drop:
      - ALL
  # readOnlyRootFilesystem: true
  runAsNonRoot: true
  runAsUser: 1000

I think this should make the Opensearch helm chart to be able to run as non-root by default.
I had already installed it on a K3S, it should run as non-root.

For Openshift, I think the users need to update the UID to the values that their namespace should use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

3 participants