Skip to content

Instantly share code, notes, and snippets.

@n2o
Last active January 18, 2022 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n2o/9d9f0a33d2f63cfe78bd3f7e92a610b9 to your computer and use it in GitHub Desktop.
Save n2o/9d9f0a33d2f63cfe78bd3f7e92a610b9 to your computer and use it in GitHub Desktop.
Fix mattermost permissions when deployed with helm

Fix Mattermost Permission Problem

This solution is based the code snippet provided @nsteinmetz in this issue.

If you deployed mattermost via the helm chart, you might experience the same problem as we at @schnaq did: the mounted volumes belong to root but not to the mattermost user. This is a problem if you want to install settings, or new plugins (e.g. the playbook or the focalboard).

To fix this, we checked the id of the mattermost user in our running pod:

kubectl exec -n mattermost -it mattermost-mattermost-team-edition-aaaaaaaaa-bbbbb id
=> uid=2000(mattermost) gid=2000(mattermost) groups=2000(mattermost)

So the current user-id of the mattermost-user is 2000.

You can then configure your helm chart to create pods which configure the correct permissions for the mattermost pod. Open the values.yaml from the mattermost helm chart and find the line extraInitContainers: [] and replace it with this snippet:

extraInitContainers:
  - name: volume-mount-hack-data
    image: busybox
    command: ["sh", "-c", "chown -R 2000:2000 /mattermost/data"]
    volumeMounts:
    - name: mattermost-data
      mountPath: /mattermost/data
  - name: volume-mount-hack-config
    image: busybox
    command: ["sh", "-c", "chown -R 2000:2000 /mattermost/config"]
    volumeMounts:
    - name: mattermost-config
      mountPath: /mattermost/config
  - name: volume-mount-hack-plugins
    image: busybox
    command: ["sh", "-c", "chown -R 2000:2000 /mattermost/client/plugins"]
    volumeMounts:
    - name: mattermost-plugins
      mountPath: /mattermost/client/plugins

Thanks for the guys in the related issues, it helped a lot ☀️

Related issues:

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