首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用NFS共享一个在Kubernetes中安装了gcs引信的卷

使用NFS共享一个在Kubernetes中安装了gcs引信的卷
EN

Stack Overflow用户
提问于 2022-09-08 12:52:45
回答 1查看 113关注 0票数 0

我一直在尝试在我们(onprem)集群中的一个吊舱中安装一个Google桶,以便使用NFS与其他吊舱和PersistentVolumes共享已安装的卷。

这里有以下几种配置:

代码语言:javascript
复制
#!/bin/bash

_start_nfs() {
  exportfs -a   
  rpcbind
  rpc.statd
  rpc.nfsd
  rpc.mountd
  GOOGLE_APPLICATION_CREDENTIALS=/accounts/key.json gcsfuse -o allow_other --dir-mode 777 --uid 1500 --gid 1500 ${BUCKET} /exports
}

_nfs_server_mounts() {
  IFS=':' read -r -a MNT_SERVER_ARRAY <<< "$NFS_SERVER_DIRS"
  for server_mnt in "${MNT_SERVER_ARRAY[@]}"; do
    if [[ ! -d $server_mnt ]]; then
        mkdir -p $server_mnt
    fi
    chmod -R 777 $server_mnt
    cat >> /etc/exports <<EOF
${server_mnt} *(rw,sync,no_subtree_check,all_squash,anonuid=1500,anongid=1500,fsid=$(( ( RANDOM % 100 )  + 200 )))
EOF
  done
  cat /etc/exports
}

_sysconfig_nfs() {
  cat > /etc/sysconfig/nfs <<EOF
#
#
# To set lockd kernel module parameters please see
#  /etc/modprobe.d/lockd.conf
#
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
RPCNFSDARGS=""
# Number of nfs server processes to be started.
# The default is 8.
RPCNFSDCOUNT=${RPCNFSDCOUNT}
#
# Set V4 grace period in seconds
#NFSD_V4_GRACE=90
#
# Set V4 lease period in seconds
#NFSD_V4_LEASE=90
#
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
RPCMOUNTDOPTS=""
# Port rpc.mountd should listen on.
#MOUNTD_PORT=892
#
# Optional arguments passed to rpc.statd. See rpc.statd(8)
STATDARG=""
# Port rpc.statd should listen on.
#STATD_PORT=662
# Outgoing port statd should used. The default is port
# is random
#STATD_OUTGOING_PORT=2020
# Specify callout program
#STATD_HA_CALLOUT="/usr/local/bin/foo"
#
#
# Optional arguments passed to sm-notify. See sm-notify(8)
SMNOTIFYARGS=""
#
# Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
RPCIDMAPDARGS=""
#
# Optional arguments passed to rpc.gssd. See rpc.gssd(8)
# Note: The rpc-gssd service will not start unless the
#       file /etc/krb5.keytab exists. If an alternate
#       keytab is needed, that separate keytab file
#       location may be defined in the rpc-gssd.service's
#       systemd unit file under the ConditionPathExists
#       parameter
RPCGSSDARGS=""
#
# Enable usage of gssproxy. See gssproxy-mech(8).
GSS_USE_PROXY="yes"
#
# Optional arguments passed to blkmapd. See blkmapd(8)
BLKMAPDARGS=""
EOF
}

### main ###
_sysconfig_nfs
_nfs_server_mounts
_start_nfs

rpcinfo -p
showmount -e

tail -f /dev/null

Dockerfile:

代码语言:javascript
复制
FROM centos:7
RUN yum -y install /usr/bin/ps nfs-utils nfs4-acl-tools curl portmap fuse nfs-utils && yum clean all
RUN mkdir -p /exports
ENV RPCNFSDCOUNT=8 \
  NFS_SERVER_DIRS='/usr'
RUN chown nfsnobody:nfsnobody /exports
RUN chmod 777 /exports
ADD setup.sh /usr/local/bin/run_nfs.sh
RUN chmod +x /usr/local/bin/run_nfs.sh
RUN useradd -u 1500 orenes
ADD gcsfuse-0.41.6-1.x86_64.rpm /data/gcsfuse-0.41.6-1.x86_64.rpm
RUN yum install -y /data/gcsfuse-0.41.6-1.x86_64.rpm

# Expose volume
VOLUME ["/exports"]

# expose mountd 20048/tcp and nfsd 2049/tcp and rpcbind 111/tcp
EXPOSE 2049/tcp 20048/tcp 111/tcp 111/udp

ENTRYPOINT ["/usr/local/bin/run_nfs.sh"]

让我们假设有一个PersistentVolume挂载了一个指向我前面描述的NFS服务器的服务。

到目前为止我被拒绝了,无法接收,等等.

我应该搬到SMB/CIFS共享吗?有什么解决办法吗?提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-09-14 10:01:56

看来FUSE和NFS在方面进展不太好。最后我使用了SMB,它运行得非常完美,但是您必须使用服务,而不是Kubernetes的DNS

@AviD中关于使用CSI的评论非常有用,如果您需要快速使用它的话。

再次感谢所有人。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73649407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档