Rancher是一个开源的企业级容器管理平台。通过Rancher,使用者再也不必自己使用一系列的开源软件去从头搭建容器服务平台。Rancher提供了在生产环境中使用的管理Docker和Kubernetes的全栈化容器部署与管理平台。
Rancher可以最大程度的降低学习成本,使得刚接触kubernetes的同学快速上手。
那么本文带来的是在TKE集群上安装Rancher
一、 安装Helm首先在控制台开通helm功能
二、下载helm client由于控制台的安装只下发了tiller、swift,还需手动下载helm client
curl -O https://storage.googleapis.com/kubernetes-helm/helm-v2.10.0-linux-amd64.tar.gz tar xzvf helm-v2.10.0-linux-amd64.tar.gz sudo cp linux-amd64/helm /usr/local/bin/helm注意,这里默认的是v2.10.0版本,client与server的版本务必对齐不然会失败。
$ helm version Client: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"} Server: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}三、初始化helm当tiller已存在的时候需加上--client-only
You might need to run helm init (or helm init --client-only if tiller is already installed)
$ helm init --client-only Creating /root/.helm Creating /root/.helm/repository Creating /root/.helm/repository/cache Creating /root/.helm/repository/local Creating /root/.helm/plugins Creating /root/.helm/starters Creating /root/.helm/cache/archive Creating /root/.helm/repository/repositories.yaml Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com Adding local repo with URL: http://127.0.0.1:8879/charts $HELM_HOME has been configured at /root/.helm. Not installing Tiller due to 'client-only' flag having been set Happy Helming!四、添加Rancher Helm ChartRancher官方提供了三种版本,分别是latest、stable、alpha。
类型
添加仓库命令
仓库描述
rancher-latest
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
Rancher server最新版Helm charts仓库,建议此仓库版本用于测试环境。好处是可试用最新功能。
rancher-stable
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
Rancher server稳定版本,推荐用于生产环境。
rancher-alpha
helm repo add rancher-alpha https://releases.rancher.com/server-charts/alpha
Rancher server Alpha版本,预览即将发布的版本。在生产环境中不建议使用这个版本。
这里我们使用stable版本
$ helm repo add rancher-stable https://releases.rancher.com/server-charts/stable五、 准备Rancher 环境1. 创建Rancher命名空间我们需要定义一个Rancher的命名空间,该命名空间中安装由Chart创建的资源。Rancher的命名空间建议始终是cattle-system
$ kubectl create namespace cattle-system2. 准备证书这一步比较麻烦,由于Rancher在2.0后的版本默认开启了TLS,所以在创建时需要先准备好证书,并且后续Rancher下发主机的探针时,会通过证书中的域名来通信。若这里是自建的证书,将会出现agent与cattle-service通信异常的情况。
所以证书是用到一个在腾讯云上申请的正式证书。
3. 创建证书secret在申请完毕后,点击下载将证书key存放至服务器上并解压
# 解压 $ unzip tencent.angryhuang.xyz.zip # 进入目录 $ cd Nginx/ $ ls 1_tencent.angryhuang.xyz_bundle.crt 2_tencent.angryhuang.xyz.key # 将证书改名 $ mv 1_tencent.angryhuang.xyz_bundle.crt tls.crt $ mv 2_tencent.angryhuang.xyz.key tls.key $ kubectl -n cattle-system create secret tls tls-rancher-ingress --cert=./tls.crt --key=./tls.key六、 创建Rancher更新列表
$ helm repo update安装rancher,并指定相关参数
$ helm install rancher-stable/rancher --name rancher --namespace cattle-system --set hostname=tencent.angryhuang.xyz --set ingress.tls.source=secret参数说明:
--name 指定helm名--namespaces 指定创建的资源放在指定的namespace下--set hostname=tencent.angryhuang.xyz 指定证书域名更多的参数设置可参考 Rancher Chart高级设置
七、修改Rancher service这里service默认创建出来的是clusterip,ingress侧无法映射Cluster IP类型的service,所以这里需要先修改成nodeport类型
将服务访问方式选择主机端口访问
八、修改 Rancher Ingress选择https,并且选择对应的域名证书,然后配置https、域名、路径、后端服务、服务端口。
九、修改域名解析为 Ingress Vip解析记录在修改成功后 600秒(10分钟)(TTL值)后生效。
十、访问域名访问域名就能成功的看到Rancher界面,首次访问需设置admin账户的密码
设置主账户的密码
设置 Rancher service URL
主界面
此时还在提醒当前集群Provisioning中...
Waiting for server-url setting to be set
这里是因为cattle-cluster-agent 还没有被创建,需要执行一定的动作才会触发下发agent的流程
等agnet启动完毕后,此时rancher搭建完成。可以体验Rancher带来的部署能力。
---来自腾讯云社区的---马凌鑫
微信扫一扫打赏
支付宝扫一扫打赏