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

Resolves mkdir permissions issue for jsonnet libraries #717

Merged
merged 5 commits into from
Apr 23, 2022

Conversation

vosmax
Copy link
Contributor

@vosmax vosmax commented Apr 9, 2022

Description

During importing jsonnet libraries from config maps by the operator, Permission access error occurs because of limited permission of the run user

2022-04-09T09:02:25.894Z	ERROR	grafana-controller	error creating jsonnet library directory for jsonnet-libs	{"error": "mkdir /opt/jsonnet/my-jsonnet-libs: permission denied"}

Type of change

Bug fix (non-breaking change which fixes an issue)

Checklist

  • This change requires a documentation update
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a test case that will be used to verify my changes
  • Verified independently on a cluster by reviewer

Verification steps

To reproduce locally

~ docker run --entrypoint "ls" -u root quay.io/grafana-operator/grafana-operator:v4.2.0 "-lah" "/opt/jsonnet"
total 12K
drwxr-xr-x 1 nobody root 4.0K Feb 22 15:34 .
drwxr-xr-x 1 root   root 4.0K Feb 22 15:34 ..
drwxr-xr-x 2 root   root 4.0K Feb 22 15:34 grafonnet

~ docker run --entrypoint "cat" -u root quay.io/grafana-operator/grafana-operator:v4.2.0 "/etc/passwd"
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin


~ docker run --entrypoint "mkdir"  quay.io/grafana-operator/grafana-operator:v4.2.0 "/opt/jsonnet/jsonnet-libs" 
mkdir: cannot create directory '/opt/jsonnet/jsonnet-libs': Permission denied

~ docker run --entrypoint "mkdir" -u nobody quay.io/grafana-operator/grafana-operator:v4.2.0 "/opt/jsonnet/jsonnet-libs"
~ 

To test on k8s cluster
Add to deployment securityContext

    spec:
      securityContext:
        runAsUser: 65534

@NissesSenap
Copy link
Collaborator

@HubertStefanski can you verify if this work as intended on OCP?

@HVBE
Copy link
Collaborator

HVBE commented Apr 12, 2022

@NissesSenap Sure, I only noticed your comment today, sorry about that! taking a look 👀

@HVBE HVBE merged commit a4beadb into grafana:master Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants