其他分享
首页 > 其他分享> > Rancher2.x部署K8 Can not find RKE state file: open /var/lib/rancher/management-state/rke/rke-32633077

Rancher2.x部署K8 Can not find RKE state file: open /var/lib/rancher/management-state/rke/rke-32633077

作者:互联网

准备两台虚拟机

192.168.64.136 rancher_server
192.168.64.137 rancher_agent

1、安装Docker

[root@rancher_server ~]# docker -v
Docker version 1.13.1, build b2f74b2/1.13.1

 

2、使用Docker运行Rancher2.2.4

[root@rancher_server ~]# docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:stable
ad11b99ced4ee85334805204d57113703b0a6812c6322b1162837fdb8c42634f
[root@rancher_server ~]# docker ps
CONTAINER ID        IMAGE                    COMMAND             CREATED             STATUS              PORTS                                      NAMES
ad11b99ced4e        rancher/rancher:stable   "entrypoint.sh"     4 seconds ago       Up 3 seconds        0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   determined_hodgkin
[root@rancher_server ~]# 

 

3、查看ip

[root@rancher_server ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:d0:11:f8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.64.136/24 brd 192.168.64.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::2037:1342:a48e:39a5/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:54:44:99:9c brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:54ff:fe44:999c/64 scope link 
       valid_lft forever preferred_lft forever
9: veth64bfc8c@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 5e:df:82:0a:e4:64 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::5cdf:82ff:fe0a:e464/64 scope link 
       valid_lft forever preferred_lft forever

 

4、访问Rancher UI

 

 设置admin密码,这里设置为123456

 

设置Rancher Server URL,Rancher Server URL是agent节点注册到rancher serverd的地址,需要保证这个地址能够被agent主机访问,不要设置为127.0.0.1或者localhost

这里设置为192.168.64.136

 

 

 

跳转到主页 https://192.168.64.136/g/clusters

 

 

切换至中文

 

 

创建K8s集群:

点击custom,添加集群名称k8sdemo,k8s版本默认v1.13.5-rancher1-3,网络组件默认canal,点击下一步

保存成功后,勾选Etcd和Control,添加rancher_agent的内网地址192.168.64.137:

 

 保存命令:sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.2.4 --server https://192.168.64.136 --token f4c7bq2cctqgbcrv9ltb74lg2w95ttrblpkdt8gz6vm8ftqsgxhtrl --ca-checksum 0b41e564684d86efc056e3e5eb31dc1f62d48c91d79ec552139461444f4441c6 --internal-address 192.168.64.137 --etcd --controlplane --worker

sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.2.4 --server https://192.168.64.136 --token f4c7bq2cctqgbcrv9ltb74lg2w95ttrblpkdt8gz6vm8ftqsgxhtrl --ca-checksum 0b41e564684d86efc056e3e5eb31dc1f62d48c91d79ec552139461444f4441c6 --internal-address 192.168.64.137 --etcd --controlplane --worker

 

 rancher_server 运行上述命令:

[root@rancher_server ~]# sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run --token f4c7bq2cctqgbcrv9ltb74lg2w95ttrblpkdt8gz6vm8ftqsgxhtrl --ca-checksum 0b41e564684d86efc056e3e5eb31dc1f62d48c91d79ec552139461444f4445633826380e89e487e4c1487b4b75a6b4af54e8b2e297d084adf3a2ab40655331444f4441c6 --internal-address 192.168.64.137 --etcd --controlplane --work
[root@rancher_server ~]# docker ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                  
5633826380e8        rancher/rancher-agent:v2.2.4   "run.sh --server h..."   8 seconds ago       Up 5 seconds                               
ad11b99ced4e        rancher/rancher:stable         "entrypoint.sh"          24 minutes ago      Up 24 minutes       0.0.0.0:80->80/tcp, 0.0
[root@rancher_server ~]# 

 

 

 点击完成。

 

 

标签:forever,file,lft,00,server,rke,state,ff,rancher
来源: https://www.cnblogs.com/wrcold520/p/10993177.html