#获取软件
wget https://get.helm.sh/helm-v3.13.2-linux-amd64.tar.gz
#解压软件
tar -zxvf helm-v3.13.2-linux-amd64.tar.gz
#加入环境变量
mv linux-amd64/helm /usr/local/bin/helm
#查看帮助
helm --help
#添加Helm Chart仓库
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
kubectl create namespace cattle-system
本次选择 SSL 配置为Rancher 生成的 TLS 证书
# 如果你手动安装了CRD,而不是在 Helm 安装命令中添加了 `--set installCRDs=true` 选项,你应该在升级 Helm Chart 之前升级 CRD 资源。
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.13.2/cert-manager.crds.yaml
# 添加 Jetstack Helm 仓库
helm repo add jetstack https://charts.jetstack.io
# 更新本地 Helm Chart 仓库缓存
helm repo update
# 安装 cert-manager Helm Chart
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.13.2
helm install rancher rancher-stable/rancher 、
--namespace cattle-system \
--set hostname=rancher.ponytest.com \
--set replicas=3 \
--set bootstrapPassword=admin
#等待 Rancher 运行,查看状态
kubectl -n cattle-system rollout status deploy/rancher
Waiting for deployment "rancher" rollout to finish: 0 of 3 updated replicas are available...
deployment "rancher" successfully rolled out
如果你看到 error: deployment "rancher" exceeded its progress deadline
这个错误,可运行以下命令来检查 deployment 的状态:
kubectl -n cattle-system get deploy rancher
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
rancher 3 3 3 3 3m
DESIRED
和 AVAILABLE
的个数应该相同
安装已完成。现在 Rancher Server 应该已经可以正常运行了。
使用浏览器打开把流量转发到你的负载均衡器的 DNS 域名。然后,你就会看到一个漂亮的登录页面了。
注:不明白负载均衡器的可直接配置本地hosts文件
10.10.114.101 rancher.ponytest.com
参考
:https://ranchermanager.docs.rancher.com/zh/v2.6/pages-for-subheaders/install-upgrade-on-a-kubernetes-cluster
附:卸载重新安装
09:38 root@k8s-rke2-worker01:~
$helm list -n cattle-system
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
rancher cattle-system 1 2023-11-28 09:15:15.405609146 +0800 CST deployed rancher-2.7.9 v2.7.9
rancher-webhook cattle-system 1 2023-11-28 01:20:05.586785713 +0000 UTC deployed rancher-webhook-2.0.6+up0.3.6 0.3.6
09:39 root@k8s-rke2-worker01:~
$helm uninstall rancher -n cattle-system
release "rancher" uninstalled
09:40 root@k8s-rke2-worker01:~
$helm list -n cattle-system
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
09:40 root@k8s-rke2-worker01:~
$helm install rancher rancher-stable/rancher --namespace cattle-system --set hostname=rancher.ponytest.com --set replicas=3 --set bootstrapPassword=admin
NAME: rancher
LAST DEPLOYED: Tue Nov 28 09:40:42 2023
NAMESPACE: cattle-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Rancher Server has been installed.
NOTE: Rancher may take several minutes to fully initialize. Please standby while Certificates are being issued, Containers are started and the Ingress rule comes up.
Check out our docs at https://rancher.com/docs/
If you provided your own bootstrap password during installation, browse to https://rancher.ponytest.com to get started.
If this is the first time you installed Rancher, get started by running this command and clicking the URL it generates:
```
echo https://rancher.ponytest.com/dashboard/?setup=$(kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}')
```
To get just the bootstrap password on its own, run:
```
kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}{{ "\n" }}'
```
Happy Containering!
09:40 root@k8s-rke2-worker01:~
$kubectl -n cattle-system rollout status deploy/rancher
Waiting for deployment "rancher" rollout to finish: 0 of 3 updated replicas are available...
Waiting for deployment "rancher" rollout to finish: 1 of 3 updated replicas are available...
deployment "rancher" successfully rolled out
09:41 root@k8s-rke2-worker01:~
$