目录
kubeasz
安装 Kubernetes
集群启用 NFS 存储,默认情况无法安装使用问题排查
kubeasz
为github
上开源项目,内部使用ansible
自动安装k8s
集群
服务 | 版本 |
---|---|
CentOS | 7.9 |
Kubernetes | 1.25 |
Kubeasz | 3.4.2 |
集群规划
节点名称 | IP地址 | 节点角色 |
---|---|---|
m1 | 192.168.100.138 | master, ansible, kubeasz |
n1 | 192.168.100.139 | node |
n2 | 192.168.100.140 | node |
安装 Kubernetes
集群
详细的安装流程 参考文档 ,需要注意参考文档中 kubeasz
版本为 3.0.1
,此处为 3.4.2
问题复现
配置文件中默认启用 nfs
存储
$ cd /etc/kubeasz/clusters/k8s
# 配置文件中启用 nfs-provisioner 作为默认的 storageclass
$ cat config.yml
......
# nfs-provisioner 自动安装
nfs_provisioner_install: "yes"
nfs_provisioner_namespace: "kube-system"
nfs_provisioner_ver: "v4.0.2"
nfs_storage_class: "managed-nfs-storage"
nfs_server: "192.168.100.138"
nfs_path: "/data/nfs"
......
安装后 nfs pod
无法启动
容器启动报错
$ kubectl -n kube-system describe pods nfs-client-provisioner-7f7b7dcb96-q9h59
# 容器日志信息
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 7m33s default-scheduler Successfully assigned kube-system/nfs-client-provisioner-7f7b7dcb96-mf8pv to 192.168.100.139
Warning FailedMount 3m17s (x2 over 5m30s) kubelet Unable to attach or mount volumes: unmounted volumes=[nfs-client-root], unattached volumes=[nfs-client-root kube-api-access-ts9gw]: timed out waiting for the condition
Warning FailedMount 76s (x3 over 5m28s) kubelet MountVolume.SetUp failed for volume "nfs-client-root" : mount failed: exit status 32
Mounting command: mount
Mounting arguments: -t nfs 192.168.100.138:/data/nfs /var/lib/kubelet/pods/867e70d9-6bee-4361-8fd8-322d3b588f29/volumes/kubernetes.io~nfs/nfs-client-root
Output: mount.nfs: Connection refused
Warning FailedMount 63s kubelet Unable to attach or mount volumes: unmounted volumes=[nfs-client-root], unattached volumes=[kube-api-access-ts9gw nfs-client-root]: timed out waiting for the condition
解决方法
[root@m1 k8s]# kubectl -n kube-system get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nfs-client-provisioner-7f7b7dcb96-xr8xt 1/1 ContainerCreating 0 8m3s 172.20.217.4 192.168.100.140 <none> <none>
- 登陆
nfs pod
所在服务器,检查nfs
服务,并挂载/data/nfs
目录
$ ssh n2
# 发现 nfs 服务默认没有启动需要启动,其他 m1 和 n1 节点也需要启动 nfs 服务
[root@n2 ~]# systemctl enable nfs --now
[root@n2 ~]# systemctl status nfs
# 挂载 /data/nfs 目录无法挂载,进程会 hang 住
[root@n2 ~]# mount -t nfs 192.168.100.138:/data/nfs /mnt
[root@n1 ~]# exportfs # 信息为空
# 其他 m1 和 n1 节点也需要启动 nfs 服务
[root@m1 ~]# systemctl enable nfs --now
[root@n1 ~]# systemctl enable nfs --now
- 登陆
m1
服务器,检查nfs
服务挂载信息是否暴露
$ cat /etc/exports # 为空
# 配置 nfs 信息,并重启服务
$ echo "/data/nfs *(rw,no_root_squash,no_all_squash,sync)" >> /etc/exports
$ systemctl restart nfs
# 登陆 n2 接重新测试
$ ssh n2
[root@n1 ~]# exportfs
/data/nfs 192.168.100.138
[root@n2 ~]# mount -t nfs 192.168.100.138:/data/nfs /mnt
[root@n2 ~]# df -h
192.168.100.138:/data/nfs 37G 14G 24G 37% /mnt
- 查看
nfs pod
服务
$ kubectl -n kube-system get pods
NAME READY STATUS RESTARTS AGE
nfs-client-provisioner-7f7b7dcb96-xr8xt 1/1 Running 0 17m
$ kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
managed-nfs-storage k8s-sigs.io/nfs-subdir-external-provisioner Delete Immediate false 38m
标签:kubeasz,data,192.168,client,nfs,provisioner,NFS,K8S,root
From: https://www.cnblogs.com/evescn/p/16996771.html