Janrs.com | 杨建勇
Janrs.com | 杨建勇

k3s/rke2 helm部署rancher

[!TIP]
helm在线部署rancher
使用的是cert-manager自动生成ssl证书
本教程的cert-managerkubectl 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
如果你有任何问题,欢迎在底部留言。或者点击加入微信技术交流群 | 我的GitHub

码仔

文章作者

Janrs.com

发表回复

textsms
account_circle
email

Janrs.com | 杨建勇

k3s/rke2 helm部署rancher
[!TIP] helm在线部署rancher 使用的是cert-manager自动生成ssl证书 本教程的cert-manager是kubectl apply安装的,不是helm安装 转载请注明出处:https://janrs.com CPU架构amd64 helm版…
扫描二维码继续阅读
2022-07-19