1. What's Rancher?
Rancher是一套容器管理平台,它可以幫助組織在生產環境中輕松快捷的部署和管理容器。 Rancher可以輕松地管理各種環境的Kubernetes,滿足IT需求並為DevOps團隊提供支持。
Kubernetes不僅已經成為的容器編排標准,它也正在迅速成為各類雲和虛擬化廠商提供的標准基礎架構。Rancher用戶可以選擇使用Rancher Kubernetes Engine(RKE)創建Kubernetes集群,也可以使用GKE,AKS和EKS等雲Kubernetes服務。 Rancher用戶還可以導入和管理現有的Kubernetes集群。
Rancher支持各類集中式身份驗證系統來管理Kubernetes集群。例如,大型企業的員工可以使用其公司Active Directory憑證訪問GKE中的Kubernetes集群。IT管理員可以在用戶,組,項目,集群和雲中設置訪問控制和安全策略。 IT管理員可以在單個頁面對所有Kubernetes集群的健康狀況和容量進行監控。
Rancher為DevOps工程師提供了一個直觀的用戶界面來管理他們的服務容器,用戶不需要深入了解Kubernetes概念就可以開始使用Rancher。 Rancher包含應用商店,支持一鍵式部署Helm和Compose模板。Rancher通過各種雲、本地生態系統產品認證,其中包括安全工具,監控系統,容器倉庫以及存儲和網絡驅動程序。下圖說明了Rancher在IT和DevOps組織中扮演的角色。每個團隊都會在他們選擇的公共雲或私有雲上部署應用程序。
2. What's New?
早期的Rancher1.X版本是基於Docker以Cattle為調度引擎的容器管理平台。在Rancher1.X成功和經驗的基礎上,基於Kubernetes基礎上重新設計Rancher2.0版本。 Rancher2.0保留了1.6版的友好功能,如UI和應用商店。但是,2.0包含許多新功能,例如:
- 內置CI/CD;
- 告警和日志收集;
- 多集群管理;
- Rancher Kubernetes Engine (RKE);
- 與雲Kubernetes服務(如GKE,EKS和AKS)集成;
3. 安裝Rancher
要想在主機上安裝Rancher,需要先登錄到主機上,接着進行以下步驟:
-
通過shell工具(例如PuTTy或遠程終端連接)登錄到主機
-
在shell中執行以下命令:
[root@localhost ~]# mkdir -p /etc/docker [root@localhost ~]# vim /etc/docker/daemon.json [root@localhost ~]# systemctl daemon-reload [root@localhost ~]# systemctl restart docker [root@localhost ~]# mkdir /rancher [root@localhost ~]# docker run -d --restart=unless-stopped -v /rancher/:/var/lib/rancher/ -p 80:80 -p 443:443 rancher/rancher:stable Unable to find image 'rancher/rancher:stable' locally stable: Pulling from rancher/rancher 7ddbc47eeb70: Pull complete c1bbdc448b72: Pull complete 8c3b70e39044: Pull complete 45d437916d57: Pull complete 28a9e619eb92: Pull complete 3922b811dfe2: Pull complete 81d9d43baeba: Pull complete ea183fe1d558: Pull complete 59cb3488b9cd: Pull complete 470bfb078fde: Pull complete 9d3364413c7e: Pull complete dcceab1151c5: Pull complete 22541110ae37: Pull complete 594323731b75: Pull complete Digest: sha256:e1da0ac036379f3bb58b3a8a94ba7f794aca9ec34bb42ca24d1e935c4a744f1e Status: Downloaded newer image for rancher/rancher:stable 5c8e861f6a7049eb86dc01fab3a4fdf99394538660c40557ad5ff7e2f6f55e8e [root@localhost ~]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5c8e861f6a70 rancher/rancher:stable "entrypoint.sh" 23 seconds ago Up 21 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp suspicious_davinci [root@localhost ~]#
4. 登錄Rancher
登錄並開始使用Rancher。登錄后,您將進行一些一次性配置。
-
打開瀏覽器,輸入
https://<server_ip>
,server_ip
替換為運行Rancher容器主機的ip; -
因為是自動使用的自簽名證書,在第一次登錄會提示安全授信問題,信任即可;
設置管理員密碼
第一次登錄會要求設置管理員密碼,默認管理員賬號為: admin
如果沒有設置密碼而要求輸入當前密碼,可以輸入密碼: admin
設置Rancher Server URL
Rancher Server URL是agent節點注冊到Rancher Serverd的地址,需要保證這個地址能夠被agent主機訪問,不要設置為127.0.0.1
或者localhost
。
5 添加k8s集群
[root@k8s-master ~]# kubectl apply -f https://192.168.180.137/v3/import/bgf67bfvhnhx6btnz4l4ktnqlzn4dq5wm942vsq7rxmv6w2zk5ht2c.yaml Unable to connect to the server: x509: certificate signed by unknown authority [root@k8s-master ~]# ll 總用量 279904 -rw-------. 1 root root 1731 12月 18 00:07 anaconda-ks.cfg drwxr-xr-x 3 root root 59 1月 7 17:20 efk -rw-r--r--. 1 root root 1779 12月 18 00:11 initial-setup-ks.cfg -rwxr-xr-x 1 root root 39305216 1月 5 19:40 kubeadm -rw-r--r-- 1 root root 1028 12月 19 22:26 kubeadm-config.yaml -rw-r--r-- 1 root root 4668 12月 19 22:20 kubeadm-init.log -rw-r--r-- 1 root root 14416 12月 19 22:36 kube-flannel.yml -rw-r--r--. 1 root root 484 12月 18 09:40 kubernetes.conf -rw-r--r-- 1 root root 199 1月 7 00:57 load-images.sh drwxr-xr-x 2 root root 315 8月 2 17:16 prometheus -rw-r--r-- 1 root root 247267436 1月 7 00:57 prometheus.tar.gz [root@k8s-master ~]# curl --insecure -sfL https://192.168.180.137/v3/import/bgf67bfvhnhx6btnz4l4ktnqlzn4dq5wm942vsq7rxmv6w2zk5ht2c.yaml | kubectl apply -f - clusterrole.rbac.authorization.k8s.io/proxy-clusterrole-kubeapiserver created clusterrolebinding.rbac.authorization.k8s.io/proxy-role-binding-kubernetes-master created namespace/cattle-system created serviceaccount/cattle created clusterrolebinding.rbac.authorization.k8s.io/cattle-admin-binding created secret/cattle-credentials-e3c7b4d created clusterrole.rbac.authorization.k8s.io/cattle-admin created deployment.apps/cattle-cluster-agent created daemonset.apps/cattle-node-agent created