[!TIP]
helm
在线部署rancher
使用的是cert-manager
自动生成ssl
证书
本教程的cert-manager
是kubectl apply
安装的,不是helm
安装转载请注明出处:https://janrs.com
CPU
架构amd64
helm
版本v3.9.4
k3s
版本1.24.4
rancher
版本v2.6
cert-manager
版本v1.9.1
helm 部署 rancher
1.下载helm
下载地址
进入下载地址下载对应的版本或者最新版
https://github.com/helm/helm/releases
解压
tar -zxvf helm-v3.9.4-linux-amd64.tar.gz
复制
cd linux-amd64 && cp helm /usr/local/bin && helm version
显示
version.BuildInfo{Version:"v3.9.4", GitCommit:"dbc6d8e20fe1d58d50e6ed30f09a04a77e4c68db", GitTreeState:"clean", GoVersion:"go1.17.13"}
2.安装cert-manager
[!NOTE]
使用自己的证书或外部负载均衡可忽略该步骤
直接从官方把yaml
文件下载下来并且替换镜像为自己的阿里私人镜像
v1.9.1
版本官网yaml
文件地址:(https://github.com/cert-manager/cert-manager/releases/download/v1.9.1/cert-manager.yaml)
下载后执行安装
kubectl apply -f cert-manager.yaml
查看
kubectl get pods -n cert-manager
显示
NAME READY STATUS RESTARTS AGE
cert-manager-546cbd665f-6f7g7 1/1 Running 0 32m
cert-manager-cainjector-84bb67964-fvpxv 1/1 Running 0 32m
cert-manager-webhook-6896c664f9-z95xq 1/1 Running 0 32m
3.安装rancher2.6
3.1 添加repo源
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
显示
"rancher-stable" has been added to your repositories
更新
helm repo update
3.2 创建命名空间
创建
kubectl create namespace cattle-system
3.3 安装
执行以下命令安装
[!NOTE]
可以指定--set hostname
参数来设置一个访问的域名地址
参数--set bootstrapPassword
设置登录的密码
helm install rancher rancher-stable/rancher \
--namespace cattle-system \
--set hostname=rancher.k3s.com \
--set replicas=1 \
--set rancherImage=registry.cn-shenzhen.aliyuncs.com/yjy_k8s/rancher \
--set bootstrapPassword=11@@33qqAA \
--set rancherImageTag=v2.7.2
1.25
版本以上添加以下参数:
--set global.cattle.psp.enabled=false
执行后显示
NAME: rancher
LAST DEPLOYED: Sat Sep 10 14:03:40 2022
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.k3s.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.k3s.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!
查看安装情况
[!NOTE]
执行安装命令后需要等待5-10
分钟让服务启动
kubectl get pods -n cattle-system -o wide
显示
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
rancher-58b9c7b76d-s9pzg 0/1 Running 1 (47s ago) 6m18s 10.42.4.3 k3s-node01 <none> <none>
等 5-10
分钟后服务全部部署完后再次查看。或者一边等一边查看
kubectl get pods --all-namespaces
发表回复