RKE2部署高可用Rancher v2.7.1
先決條件
- 注意修改主機名,不要有沖突
第一個server節點安裝
官方文檔的描述感覺對于新手來說太不友好了,建議以下鏈接都看一下。Rancher新老文檔都建議看一下,不然剛剛入門很蒙。
RKE2快速開始:https://docs.rke2.io/zh/install/quickstart
RKE2高可用:https://docs.rke2.io/zh/install/ha
RKE2離線安裝:https://docs.rke2.io/zh/install/airgap
RKE2卸載:https://docs.rke2.io/zh/install/linux_uninstall
Rancher Helm CLI快速入門:https://ranchermanager.docs.rancher.com/zh/getting-started/quick-start-guides/deploy-rancher-manager/helm-cli
Rancher 離線Helm安裝:https://ranchermanager.docs.rancher.com/zh/getting-started/installation-and-upgrade/other-installation-methods/air-gapped-helm-cli-install/install-rancher-ha
老版Rancher文檔 離線安裝:https://docs.rancher.cn/docs/rancher2/installation/other-installation-methods/air-gap/install-rancher/_index
老版Rancher文檔 如何在國內使用 Rancher:https://docs.rancher.cn/docs/rancher2/best-practices/use-in-china/_index/
# 卸載 /usr/local/bin/rke2-uninstall.shmkdir -p /etc/rancher/rke2 && echo system-default-registry: "docker.nju.edu.cn" > /etc/rancher/rke2/config.yaml # 指定版本安裝 curl -sfL https://rancher-mirror.rancher.cn/rke2/install.sh | INSTALL_RKE2_MIRROR=cn INSTALL_RKE2_VERSION=v1.22.17+rke2r1 sh - # 安裝最新stable版本 # curl -sfL https://rancher-mirror.rancher.cn/rke2/install.sh | INSTALL_RKE2_MIRROR=cn sh - systemctl enable rke2-server.service && systemctl start rke2-server.service# 查看日志 # journalctl -u rke2-server -f# 注冊令牌,接下來要用 cat /var/lib/rancher/rke2/server/node-token配置負載均衡器和健康檢查
我這里使用的是VMware NSX-T負載均衡
這里有個坑,80端口的響應代碼,需要把307,308,303標記為健康的狀態碼
其他server節點安裝
# 配置文件,load_balancer_addr 負載均衡ip或者第一臺serverip load_balancer_addr=172.16.10.241 node_token=xxxxxxxxmkdir -p /etc/rancher/rke2 && echo " server: https://${load_balancer_addr}:9345 token: ${node_token} tls-san:- ${load_balancer_addr} system-default-registry: \"docker.nju.edu.cn\" " > /etc/rancher/rke2/config.yaml# 檢查配置 cat /etc/rancher/rke2/config.yaml# 安裝 curl -sfL https://rancher-mirror.rancher.cn/rke2/install.sh | INSTALL_RKE2_MIRROR=cn INSTALL_RKE2_VERSION=v1.22.17+rke2r1 sh - systemctl enable rke2-server.service && systemctl start rke2-server.service實用程序注冊到PATH
echo 'export PATH=$PATH:/var/lib/rancher/rke2/bin;' >> ~/.bashrc && source ~/.bashrc mkdir -p ~/.kube && rm -f ~/.kube/config && ln -s /etc/rancher/rke2/rke2.yaml ~/.kube/config安裝helm
# 下載 helm 并上傳 https://github.com/helm/helm/releases rm -rf linux-amd64/helm && tar -zxvf helm-v3.10.3-linux-amd64.tar.gz && mv linux-amd64/helm /usr/local/bin/helm && helm version安裝Cert-Manager
# 可以下載過來然后在 kubectl apply -f cert-manager.crds.yaml kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.crds.yamlhelm repo add jetstack https://charts.jetstack.io && helm repo updatehelm install cert-manager jetstack/cert-manager \ --set image.repository=quay.nju.edu.cn/jetstack/cert-manager-controller \ --set webhook.image.repository=quay.nju.edu.cn/jetstack/cert-manager-webhook \ --set cainjector.image.repository=quay.nju.edu.cn/jetstack/cert-manager-cainjector \ --set startupapicheck.image.repository=quay.nju.edu.cn/jetstack/cert-manager-ctl \ --namespace cert-manager \ --create-namespace \ --version v1.7.1安裝Rancher
這里也有個坑,不能安裝離線安裝文檔中加
--set certmanager.version=<CERTMANAGER_VERSION> 參數,會報錯如下
unable to build kubernetes objects from release manifest: resource mapping not found for name: "rancher" namespace: ""
安裝完成
密碼看提示
$(kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}')
或者直接用鏈接(其實就是跳過輸入上面隨機密碼的階段,直接到下一步設置admin密碼)
echo https://rancher01.ent.top/dashboard/?setup=$(kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}')
總結
以上是生活随笔為你收集整理的RKE2部署高可用Rancher v2.7.1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 高防IP和云防护的好处
- 下一篇: ProE打开服务器文件路径添加,【1人回