Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the hostPath volume permission on kubernetes?

Tags:

kubernetes

It seems by default Kubernetes creates a hostPath volume with 755 permission on a directory.

Is it possible to set this value to something else by a volume spec? As opposed to manually doing a chmod on the relevent host directory.

like image 423
Chris Stryczynski Avatar asked Jun 08 '18 17:06

Chris Stryczynski


People also ask

What is hostPath in persistent volume?

A hostPath volume mounts a file or directory from the host node's file system into your pod. For more information about hostPath volume, see Types of Volumes . A hostPath PersistentVolume must be used only in a single-node cluster. Kubernetes does not support hostPath on a multi-node cluster currently.

What is Kubernetes hostPath?

A Kubernetes hostpath is one of the volumes supported by Kubernetes. It is used to mount a file or directory from the host node's file system into our pod. It does not require most pods. However, it is instrumental in testing or development scenarios and provides a powerful escape for some applications.


1 Answers

  initContainers:
    - name: volume-mount-hack
      image: busybox
      command: ["sh", "-c", "chmod -R 777 /tmp/docker"]
      volumeMounts:
      - name: redis-socket
        mountPath: /tmp/docker
like image 118
Chris Stryczynski Avatar answered Sep 21 '22 09:09

Chris Stryczynski