一、概述
Rancher2.5.x支持多種高可用安裝,官方發佈一款名爲RancherD的工具,可以傻瓜化安裝高可用集羣。
二、安裝
1、使用root登錄服務器
2、新建配置文件/etc/rancher/rke2/config.yaml
token: my-shared-secret
tls-san:
- my-fixed-registration-address.com
注意其中token是其它節點加入集羣的憑證;my-fixed-registration-address.com是你實際的master域名,比如master.rancher.com,此域名可設置多個;
3、下載RancherD
curl -sfL https://get.rancher.io | INSTALL_RANCHERD_VERSION=v2.5.9-rc3 sh -
4、啓動
systemctl enable rancherd-server.service
systemctl start rancherd-server.service
5、等待啓動安裝完成,此時可執行如下命令查看安裝日誌
journalctl -eu rancherd-server -f
當看到如下內容,即代表安裝完成:
7月 01 15:10:15 rancherd-master rancherd[3395]: time="2021-07-01T15:10:15+08:00" level=info msg="Handling backend connection request [rancherd-master]"
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.536804 3395 node_controller.go:115] Sending events to api server.
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.536894 3395 controllermanager.go:285] Started "cloud-node"
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.537067 3395 node_controller.go:154] Waiting for informer caches to sync
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.538293 3395 node_lifecycle_controller.go:76] Sending events to api server
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.538361 3395 controllermanager.go:285] Started "cloud-node-lifecycle"
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.637720 3395 node_controller.go:390] Initializing node rancherd-master with cloud provider
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.642797 3395 node_controller.go:454] Successfully initialized node rancherd-master with cloud provider
7月 01 15:10:15 rancherd-master rancherd[3395]: I0701 15:10:15.643827 3395 event.go:291] "Event occurred" object="rancherd-master" kind="Node" apiVersion="v1" type="Normal" reason="Synced" message="Node synced successfully"
6、設置kubeconfig
export KUBECONFIG=/etc/rancher/rke2/rke2.yaml PATH=$PATH:/var/lib/rancher/rke2/bin
7、驗證安裝
輸入驗證命令,輸出如下內容時表示安裝完成。
root@rancherd-master:/etc/rancher/rke2# kubectl get daemonset rancher -n cattle-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
rancher 1 1 0 1 0 node-role.kubernetes.io/master=true 6s
root@rancherd-master:/etc/rancher/rke2# kubectl get pod -n cattle-system
NAME READY STATUS RESTARTS AGE
rancher-56gns 0/1 ContainerCreating 0 13s
8、初始化密碼
root@rancherd-master:/etc/rancher/rke2# rancherd reset-admin
INFO[0002] Server URL: https://my-fixed-registration-address.com:8443
INFO[0002] Default admin and password created. Username: admin, Password: 4s6chmgj92cfrv2hxvv9vfgq25nw5rwt7kgvx7cpc5kc6jz9wbw82w
9、打開瀏覽器,輸入 https://my-fixed-registration-address.com:8443 ,設置新admin密碼後正式安裝完成!
三、擴容
通常推薦3臺機器組成master集羣。
1、在新機器新建配置文件/etc/rancher/rke2/config.yaml
server: https://my-fixed-registration-address.com:9345
token: my-shared-secret
tls-san:
- my-fixed-registration-address.com.
主要區別是增加了sever指向第一臺master
2、執行
curl -sfL https://get.rancher.io | INSTALL_RANCHERD_VERSION=v2.5.9-rc3 sh -
systemctl enable rancherd-server.service
systemctl start rancherd-server.service
3、等待加入完成即可。