AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1146937
Accepted
roy
roy
Asked: 2023-10-31 21:57:46 +0800 CST2023-10-31 21:57:46 +0800 CST 2023-10-31 21:57:46 +0800 CST

无法通过服务端点访问 Kubernetes NFS 服务器

  • 772

我已经使用以下清单部署了 NFS 服务器

---

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: nfs-pv-provisioning-demo
  namespace: nfs
  labels:
    role: nfs-server
spec:
  storageClassName: aws-gp3
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-server
  namespace: nfs
spec:
  replicas: 1
  selector:
    matchLabels:
      role: nfs-server
  template:
    metadata:
      labels:
        role: nfs-server
    spec:
      containers:
      - name: nfs-server
        image: registry.k8s.io/volume-nfs:0.8
        ports:
          - name: nfs
            containerPort: 2049
          - name: mountd
            containerPort: 20048
          - name: rpcbind
            containerPort: 111
        securityContext:
          privileged: true
        volumeMounts:
          - mountPath: /exports
            name: mypvc
      volumes:
        - name: mypvc
          persistentVolumeClaim:
            claimName: nfs-pv-provisioning-demo

---

kind: Service
apiVersion: v1
metadata:
  name: nfs-server
  namespace: nfs
spec:
  ports:
    - name: nfs
      port: 2049
    - name: mountd
      port: 20048
    - name: rpcbind
      port: 111
  selector:
    role: nfs-server

---

但是当我使用nfs-server.nfs.svc.cluster.local服务器名称时,它无法解析它。当我使用集群 IP 作为服务端点时,它起作用了。

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs
  namespace: nfs
spec:
  capacity:
    storage: 1Mi
  accessModes:
    - ReadWriteMany
  nfs:
    server: nfs-server.nfs.svc.cluster.local
    # server: 172.20.144.30
    path: "/"
  mountOptions:
    - nfsvers=4.2

知道这个设置有什么问题吗?

kubernetes
  • 1 1 个回答
  • 24 Views

1 个回答

  • Voted
  1. Best Answer
    aboitier
    2023-10-31T23:40:39+08:002023-10-31T23:40:39+08:00

    这是 Kubernetes 中的一个已知错误:可能是在 pod 到达内部 DNS 之前设置 NFS 服务器的初始化问题。

    肮脏的解决方案:如果你想保留nfs-server.nfs.svc.cluster.local,你可以编辑每个节点上的 /etc/hosts 文件,其中包含nfs-server.nfs.svc.cluster.localIP 旁边的内容:

    $ cat /etc/hosts
    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1       localhost
    255.255.255.255 broadcasthost
    ::1             localhost
    172.20.144.30   nfs-server.nfs.svc.cluster.local
    

    您可以在这里找到更多信息: https: //github.com/kubernetes/minikube/issues/3417或通过谷歌搜索server: nfs-server.nfs.svc.cluster.local

    • 2

相关问题

  • Nvidia Config 后 Containerd 无法启动

  • 在使用 kubeadm 引导集群之前,如何修改 CoreDNS 配置映射?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve