-
Notifications
You must be signed in to change notification settings - Fork 16.7k
added security context to template if using persisted volumes #6428
Conversation
Question Why do you use 472 as fsGroup ? |
472 is the uid of the grafana user the upstream docker image creates and uses to run grafana in the container. Without this, grafana doesn't have access to persistent volumes, and will failed due to insufficient permissions. |
Ok I'm not an expert in rbac.psp so may I do a mistake but have you think about people who use rbac.pspEnable: false ? in this case it may not work isn't it ? |
I'm not very familiar with pod security policies, but this PR addresses the linux systems permissions issue in the issue linked to above specifically that stems from the grafana team updating their image. If this won't work for those disabling psp, I'd love to know about it, and what a possible work around might be. |
@RyanHartje I am getting this issue when trying to create Grafana with a persistence turned on in the values.yaml. |
@antodoms I'm sorry, I don't quite understand. Do you mean that you're also getting issues when enabling persistence with the current Grafana charts, or do you mean that you receive an error with my changes in the Grafana chart when enabling persistent volumes? Thank you for your help. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions. |
I've been getting a lot of github notifications for this issue where I filed it in Grafana. Here's a walkthrough of the problem this PR seeks to solve (copied from an issue filed in Grafana). The helm chart has broken linux permissions when mounting a volume for persistence. Within the docker image for grafana, we create the user grafana, with a uid of 472: We then give this user parts of the filesystem ownership here: The issue being reported is when helm mounts a volume over /var/lib/grafana, the ownership is changed to the default (root:root). Here's a walk through of issue replication and identification. Steps: Start Minikube▶ minikube start
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
160.27 MB / 160.27 MB [==================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file. Init Helm
Modify Grafana values to persist dataCopy default values file (https://github.com/helm/charts/blob/master/stable/grafana/values.yaml) Modify:
to
Run helm install
Inspect persisted volume permissionsHere's the deployment template for Grafana in it's helm chart: Since we see it will be mounted at /var/lib/grafana, let's check out perms in there:
What does this look like by default without persistence?
This causes data to be unreadable by the grafana user, making a chart deployed with a persistent volume now useable since grafana 5.1.2 (guesstimate). |
/ok-to-test |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: RyanHartje If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@RyanHartje: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Looks like this is already resolved, closing. |
What this PR does / why we need it:
This chart is broken when using a PVC with updated versions of Grafana.
Grafana now runs as a non privileged user, with uid 472.
This PR ensures that if we're using a persistent volume, that it has the right access and perms to write to disk.
Which issue this PR fixes
fixes grafana-docker #167
grafana/grafana-docker#167 (comment)
Special notes for your reviewer: