–
问题:当pod启动挂载node的目录的时候,如果node父目录不存在,会递归创建,但是父目录属主属组为root,具体看下面链接
https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
pod启动的时候会切换到andblog用户,在挂载目录里面创建子目录,andblog用户没有权限,下面刚刚node目录属主属组为解决此问题
下面是具体需要执行的命令,来监听/data/script; cd /data/script;目录,当有此目录递归创建的时候,会自动将目录的属主属组更改为docker用户
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p; \
yum install -y inotify-tools; \
mkdir -p /data/script; cd /data/script; \
wget http://yum.andblog.com/script/watch_file.sh; \
echo "nohup /bin/bash /data/script/watch_file.sh &" >> /etc/rc.local; \
nohup /bin/bash /data/script/watch_file.sh &
具体脚本内容如下
cat watch_file.sh
#!/bin/bash
cd $(dirname $0)
func_watch_file(){
/usr/bin/