gitlab 部署失败Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data]'

  • Choerodon平台版本: 0.9.0

  • 遇到问题的执行步骤:
    一键部署

  • 环境信息(如:节点信息):
    choerodon-gitlab-758b875586-fxlds

  • 报错日志:
    choerodon-gitlab-758b875586-fxlds pod日志:

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

If this container fails to start due to permission problems try to fix it by executing:

  docker exec -it gitlab update-permissions
  docker restart gitlab

Preparing services...
Starting services...
Configuring GitLab package...
/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system
gitlab preinstall:
gitlab preinstall: This node does not appear to be running a database
gitlab preinstall: Skipping version check, if you think this is an error exit now
gitlab preinstall:
Configuring GitLab...

================================================================================
Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data]'
================================================================================

Mixlib::ShellOut::ShellCommandFailed

如果你使用自己搭建的k8s,需要特别注意网络和存储权限,如在某些网络组件上默认禁止了不同namespace间的网络通信。在高版本的k8s中已默认禁止了configmap的写权限等。

helm install c7n/gitlab \
    --set persistence.enabled=true \
    --set persistence.existingClaim=${RELEASE_PREFIX}choerodon-gitlab-pvc \

挂载pv就会报错。使用本机存储–set persistence.enabled=false 可以部署成功

我把k8s版本降到1.8,这个问题还是同样存在。

查看下你的绑定到gitlab的目录的权限,你是否用root用户创建的nfs文件目录?

$ ls -lh | grep gitlab
# drwxr-xr-x  3 root root 4.0K May 18 18:16 gitlab

是的 初始化是用root创建的

是需用用root创建吗? 正确的权限是什么?

在nfs服务器上查看是root
[root@sh2nfsserverj64 io-choerodon]# ls -lh | grep gitlab
drwxr-xr-x 2 root root 4.0K 9月 11 11:02 gitlab

挂载到客户端变成nobody
[root@ofck8snode01 io-choerodon]# ls -lh | grep gitlab
drwxr-xr-x 2 nobody nobody 4.0K 9月 11 11:02 gitlab

尝试下下面步骤
1.删除gitlab文件夹
2.使用root用户登录一个非nfs服务器的主机
3.创建一个临时文件夹

 mkdir /tmpnfs
  1. 绑定nfs
mount -t nfs 192.168.xxx.xxxx:/u01 /tmpnfs/
  1. 重新创建文件夹
cd  /tmpnfs/io-choerodon
mkdir gitlab
  1. 再次查看是否是属于root用户
$ ls -lh
# total 4.0K
# drwxr-xr-x 2 root root 4.0K Sep 11  2018 gitlab

服务默认使用root用户,对应nfs中指定文件夹都应该属于root用户,如果你使用一个nobody的用户创建就会导致存在权限问题。后续的mysql等也可能出现同样的问题

造成该问题的原因是,在centos 6版本中默认使用的nfs-v4版本,其提供了称为rpc.idmapd 的守护进程,并使用 /etc/idmapd.conf 的配置文件。当请求加载nfsv4 时,该守护进程将处理 UID 和 GID 映射。默认使用nis,没有nis它会自动映射成nobody用户。

既然找到了原因,找解决方法也就不难了,大致找了下网上的解决方法,分如下两种。

方法一:mount中指定参数法

在mount挂载的时候指定使用v3版本去挂载,如下:

mount -t nfs -o vers=3 ip:/data1 /data1
显然不推荐该方法,既然有了V4版本,其肯定较V3版本做了很多优化,如果再用V3,显然跟不上时代的步伐 。

用这种情况就是root权限了。 我再试试。谢谢!

我们建议使用centos7.2以上的系统,默认即为root权限。

[root@ofck8snode01 u01]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

我的系统是7.5的

现在权限都是root 但是还是一样的问题 你们部署的时候没遇到过吗

请检查下你的nfs服务是否配置有问题,能够粘贴下 NFS服务器中这个文件的内容

cat /etc/exports

/u01 192.168..(insecure,rw,sync,no_root_squash)

调成如下试试:

/u01 192.168.0.0/16(rw,sync,no_root_squash,no_all_squash) 

一样的问题。
我看了其实就是在pod里面通过nfs挂载的/var/opt/gitlab的用户属主是属于nfsnobody:nfsnobody
git安装脚本判断不属于git:git就return 1报错退出