Opening storage failed mkdir data/: permission denied

2,806 views
Skip to first unread message

suyog.k...@gslab.com

unread,
May 10, 2018, 3:02:51 AM5/10/18
to Prometheus Users
Hi ,

I am using prometheus 2.2.1 . I am trying to mount the /prometheus directory of prometheus pod on host.
   
   volumeMounts
   - name: prometheus-data
     mountPath: /prometheus
volumes
- name: prometheus-data
  hostPath:
    path: /var/lib/prometheus-tsdb

I am getting following error :

Opening storage failed mkdir data/: permission denied.

Please Help

Chris Marchbanks

unread,
May 10, 2018, 8:30:15 AM5/10/18
to suyog.k...@gslab.com, Prometheus Users
By default Prometheus tries to write data to the data/ directory. To use your mounted directory you can set the flag --storage.tsdb.path=/prometheus in the args you pass to Prometheus.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/467fcfdb-cc8a-4572-8c51-5efbfd329711%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Chris Marchbanks | Engineer
FreshTracks.io - Intelligent Alerting for Kubernetes and Prometheus

Cody Boggs

unread,
May 11, 2018, 11:15:14 AM5/11/18
to Chris Marchbanks, suyog.k...@gslab.com, Prometheus Users
One small addition, as of Prometheus 2.x, and Kubernetes > 1.9-ish, Kubernetes deployments need to specify a SecurityContext for the pod to be able to write to whatever directory you've mounted. Add this block, as-is, at the same indentation level as "volumes:" (in words, as part of the pod spec, not a container spec):
securityContext:
  fsGroup: 2000
  runAsNonRoot: true
  runAsUser: 1000

And it should help. :-)

Cody Boggs | Yak Shaver (Ops)

FreshTracks.io

Intelligent Alerting for Kubernetes and Prometheus

Reply all
Reply to author
Forward
0 new messages