Root password for container containing grafana

Hi,

I need to update grafana.ini file which has read/write permission for root. I am logged in via grafana user and don’t know the password for root container . I have installed grafana on kubernetes using helm chart. Below contains rest of the details.

C:\WINDOWS\system32>kubectl exec -it prometheus-grafana-798d5675bf-vf2nb -n monitoring --container grafana – /bin/bash
grafana@prometheus-grafana-798d5675bf-vf2nb:/usr/share/grafana$ cd /etc/grafana/
grafana@prometheus-grafana-798d5675bf-vf2nb:/etc/grafana$ ls -lrth
total 12K
drwxr-xr-x 1 root root 4.0K Nov 13 2018 provisioning
-rw-r–r-- 1 root grafana 235 Dec 10 07:25 grafana.ini
-rw-r–r-- 1 root grafana 0 Dec 10 07:25 ldap.toml

Can somebody let me know how to get the password of root user in grafana container.

to get root, you would just pass -u 0 to the docker container when you exec

Hi @bkgann

Thanks for the reply. Did you mean below command. This is not executing :

C:\WINDOWS\system32>kubectl exec -it prometheus-grafana-798d5675bf-vf2nb -n monitoring --container grafana -u 0 – /bin/bash

You’d have to ssh into the node where the pod is running, then use docker exec from there to specify the -u 0 argument.

I don’t see support for kubectl passing this argument. I do see an extension though (have not tried it): https://github.com/jordanwilson230/kubectl-plugins/tree/krew#kubectl-exec-as

There’s a helper script also that does the below steps: https://github.com/kubernetes/kubernetes/issues/30656#issuecomment-476872519

Process would be like this:

Find the node it is running on:

kubectl get po -n monitoring -o wide

ssh into the node, and:

sudo docker ps | grep monitoring

get the dockerid from above

sudo docker exec -it -u 0 [DOCKER ID] /bin/bash