Alibaba Nacos 学习(一):Nacos介绍与安装
Alibaba Nacos 学习(二):Spring Cloud Nacos Config
Alibaba Nacos 学习(三):Spring Cloud Nacos Discovery - FeignClient,Nacos 服务注册与发现
Alibaba Nacos 学习(四):Nacos Docker
Alibaba Nacos 学习(五):K8S Nacos搭建,使用nfs
准备环境
Centos7 192.168.50.21 k8s-master 2G
Centos7 192.168.50.22 k8s-node01 2G
Centos7 192.168.50.23 k8s-node02 2G
K8S集群搭建参考 https://www.cnblogs.com/woxpp/p/11875547.html
master安装好Git ,yum install git
master,node01,node02 安装 nfs-utils
yum install nfs-utils
master,node01,node02添加nfs exports配置,为了解决后续的nfs报错异常
/data/mysql-slave *(insecure,fsid=0,rw,async,no_root_squash) /data/mysql-master *(insecure,fsid=0,rw,async,no_root_squash) /data/nfs-share *(rw,fsid=0,sync,no_root_squash)
mysql-slave 数据库从库
mysql-master 数据库主库
nfs-share nocas文件挂在目录后面的yml中会提到master,node01,node02创建目录
mkdir /data/mysql-slave mkdir /data/mysql-master mkdir /data/nfs-share
master 克隆代码
git clone https://github.com/nacos-group/nacos-k8s.git
克隆完成进入以下目录
cd /opt/nacos-k8s/deploy/
1.nfs安装
kubectl create -f nfs/rbac.yaml
kubectl create -f nfs/class.yaml
修改nfs/deployment.yaml IP配置
kubectl create -f nfs/deployment.yaml
查看安装状态
kubectl get pod -l app=nfs-client-provisioner
2.mysql部署
cd /opt/nacos-k8s/deploy/mysql/
修改数据配置文件ip
vi mysql-master-nfs.yaml
部署主库
kubectl create -f mysql-master-nfs.yaml
修改存库ip
vi mysql-slave-nfs.yaml
kubectl create -f mysql-slave-nfs.yaml
主从部署非常慢 耐心等待,如果报nfs相关的错,重启nfs即可
service nfs restart
3. 部署nacos
cd /opt/nacos-k8s/deploy/nacos/
kubectl create -f nacos-pvc-nfs.yaml
查看访问端口
kubectl get svc|grep nacos
查看K8S集群状态
Failed to pull image "nacos/nacos-server:latest": rpc error: code = Unknown desc = context canceled
进去对应节点机器 ,拉取镜像后,重新应用即可
kubectl apply -f
4. 部署问题
部署过程中大部分都是NFS问题
可以参考https://blog.csdn.net/wuxinyicomeon/article/details/6292132
mount.nfs: No route to host
Warning FailedMount 100s (x5 over 10m) kubelet, node2 Unable to mount volumes for pod "nfs-client-provisioner-594f778474-whhb5_default(56aef93a-9d31-11e9-a4c4-00163e069f44)": timeout expired waiting for volumes to attach or mount for pod "default"/"nfs-client-provisioner-594f778474-whhb5". list of unmounted volumes=[nfs-client-root]. list of unattached volumes=[nfs-client-root nfs-client-provisioner-token-8dcrx]
修改deployment.yaml中server的IP地址为某个node节点的内网IP地址,图1已标注