1.docker安装rancher
[root@rancher ~]# docker run -d --name rancher --restart=unless-stopped -p 80:80 -p 443:443 -v /opt/rancher:/var/lib/rancher rancher/rancher:v2.2.4Unable to find image 'rancher/rancher:v2.2.4' locallyTrying to pull repository docker.io/rancher/rancher ... v2.0.0: Pulling from docker.io/rancher/rancher68393378db12: Pull complete 9e3366501e0e: Pull complete 156ec05da9a5: Pull complete 281cba1133d9: Pull complete 0acdc2cc8ed1: Pull complete a8cef3d8a877: Pull complete 3e968117f1c2: Pull complete cf62fef10dfd: Pull complete 098edd097869: Pull complete 77a837c0bf2d: Pull complete Digest: sha256:38839bb19bdcac084a413a4edce7efb97ab99b6d896bda2f433dfacfd27f8770Status: Downloaded newer image for docker.io/rancher/rancher:v2.0.0215f26faeda5d32f18a25c23cfac4c2ea4d99643f0499163bdc0e06e3ca96336[root@rancher ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES215f26faeda5 rancher/rancher:v2.2.4 "rancher --http-li..." 9 seconds ago Up 8 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp rancher
2.倒入集群
浏览器访问本机的ip,然后设置密码登陆上去,点击add cluster,选择import倒入现有集群
复制上面的其中一个到现有集群的master节点去执行
这里我们单独下载来执行
[root@master rancher]# wget --no-check-certificate https://10.0.1.186/v3/import/8xhq4r95ptgghqbwx2sgf8t8vlvt5sg6wcqmvspwmn72dh4r7mp9lg.yaml--2019-06-19 23:35:56-- https://10.0.1.186/v3/import/8xhq4r95ptgghqbwx2sgf8t8vlvt5sg6wcqmvspwmn72dh4r7mp9lg.yamlConnecting to 10.0.1.186:443... connected.WARNING: cannot verify 10.0.1.186's certificate, issued by ‘/O=the-ranch/CN=cattle-ca’: Unable to locally verify the issuer's authority.HTTP request sent, awaiting response... 200 OKLength: unspecified [text/plain]Saving to: ‘8xhq4r95ptgghqbwx2sgf8t8vlvt5sg6wcqmvspwmn72dh4r7mp9lg.yaml’ [ <=> ] 3,426 --.-K/s in 0s 2019-06-19 23:35:56 (56.1 MB/s) - ‘8xhq4r95ptgghqbwx2sgf8t8vlvt5sg6wcqmvspwmn72dh4r7mp9lg.yaml’ saved [3426][root@master rancher]# mv 8xhq4r95ptgghqbwx2sgf8t8vlvt5sg6wcqmvspwmn72dh4r7mp9lg.yaml rancher-import.yaml[root@master rancher]# kubectl apply -f rancher-import.yaml namespace/cattle-system createdserviceaccount/cattle createdclusterrolebinding.rbac.authorization.k8s.io/cattle createdsecret/cattle-credentials-db8ed0c createddeployment.extensions/cattle-cluster-agent createddaemonset.extensions/cattle-node-agent created[root@master rancher]# kubectl get pod -n cattle-systemNAME READY STATUS RESTARTS AGEcattle-cluster-agent-5b98f69764-cmhwt 0/1 ContainerCreating 0 2m14scattle-node-agent-4gxlt 0/1 ContainerCreating 0 2m14scattle-node-agent-l2zmg 0/1 ContainerCreating 0 2m14s
等待一段时间,镜像下载完毕
[root@master rancher]# kubectl get pod -n cattle-system -owideNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATEScattle-cluster-agent-5b98f69764-cmhwt 1/1 Running 0 18m 10.244.2.41 node01cattle-node-agent-4gxlt 1/1 Running 0 18m 10.0.1.229 node01 cattle-node-agent-l2zmg 1/1 Running 0 18m 10.0.1.7 node02
回到浏览器发现集群已经倒入,但是还有错误
Exit status 1, W0619 16:36:49.951709 16814 factory_object_mapping.go:423] Failed to download OpenAPI (the server could not find the requested resource), falling back to swagger error: error validating "management-state/tmp/yaml-787242553": error validating data: the server could not find the requested resource; if you choose to ignore these errors, turn validation off with --validate=false