安装rancher以及使用rancher倒入kubernetes集群和添加及管理集群

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.0.0
Unable to find image 'rancher/rancher:v2.0.0' locally
Trying to pull repository docker.io/rancher/rancher ... 
v2.0.0: Pulling from docker.io/rancher/rancher
68393378db12: 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:38839bb19bdcac084a413a4edce7efb97ab99b6d896bda2f433dfacfd27f8770
Status: Downloaded newer image for docker.io/rancher/rancher:v2.0.0
215f26faeda5d32f18a25c23cfac4c2ea4d99643f0499163bdc0e06e3ca96336
[root@rancher  ~]# docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                                      NAMES
215f26faeda5        rancher/rancher:v2.0.0   "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.yaml
Connecting 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 OK
Length: 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 created
serviceaccount/cattle created
clusterrolebinding.rbac.authorization.k8s.io/cattle created
secret/cattle-credentials-db8ed0c created
deployment.extensions/cattle-cluster-agent created
daemonset.extensions/cattle-node-agent created
[root@master rancher]# kubectl get pod -n cattle-system
NAME                                    READY   STATUS              RESTARTS   AGE
cattle-cluster-agent-5b98f69764-cmhwt   0/1     ContainerCreating   0          2m14s
cattle-node-agent-4gxlt                 0/1     ContainerCreating   0          2m14s
cattle-node-agent-l2zmg                 0/1     ContainerCreating   0          2m14s

等待一段时间,镜像下载完毕

[root@master rancher]# kubectl get pod -n cattle-system -owide
NAME                                    READY   STATUS    RESTARTS   AGE   IP            NODE     NOMINATED NODE   READINESS GATES
cattle-cluster-agent-5b98f69764-cmhwt   1/1     Running   0          18m   10.244.2.41   node01   <none>           <none>
cattle-node-agent-4gxlt                 1/1     Running   0          18m   10.0.1.229    node01   <none>           <none>
cattle-node-agent-l2zmg                 1/1     Running   0          18m   10.0.1.7      node02   <none>           <none>

回到浏览器发现集群已经倒入,但是还有错误

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

猜你喜欢

转载自www.cnblogs.com/linyouyi/p/11056053.html