惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
V
V2EX
博客园_首页
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
H
Help Net Security
A
About on SuperTechFans
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
云风的 BLOG
云风的 BLOG
D
Docker
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
N
News and Events Feed by Topic
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
A
Arctic Wolf
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
aimingoo的专栏
aimingoo的专栏
Hacker News: Ask HN
Hacker News: Ask HN
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy International News Feed
T
Troy Hunt's Blog
T
Tenable Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Recorded Future
Recorded Future
F
Fortinet All Blogs
D
DataBreaches.Net
B
Blog
T
Threat Research - Cisco Blogs
MyScale Blog
MyScale Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
The GitHub Blog
The GitHub Blog
Security Latest
Security Latest
M
MIT News - Artificial intelligence

二丫讲梵

学习周刊-总第258期-2026年第15周 学习周刊-总第257期-2026年第14周 学习周刊-总第256期-2026年第13周 学习周刊-总第255期-2026年第12周 学习周刊-总第254期-2026年第11周 学习周刊-总第253期-2026年第10周 临时插播一条羊毛,免费领取450元大模型API代金券 学习周刊-总第252期-2026年第09周 学习周刊-总第251期-2026年第08周 学习周刊-总第250期-2026年第07周 学习周刊-总第249期-2026年第06周 诚邀评论,聊聊你所知欲知的我 学习周刊-总第248期-2026年第05周 我的QQ动态之2015年 我的QQ动态之2014年 我的QQ动态之2013年 我的QQ动态之2012年 我的QQ动态-2010-2011年 我的QQ动态-创栏小叙 学习周刊-总第247期-2026年第04周 Nexus社区版权益阉割--一文告诉你有哪些版本可以选择 学习周刊-总第246期-2026年第03周 学习周刊-总第245期-2026年第02周 学习周刊-总第244期-2026年第01周 学习周刊-总第243期-2025年第52周 学习周刊-总第242期-2025年第51周 开源项目ZenOps:带你领略禅意运维 学习周刊-总第241期-2025年第50周 用京东金融,享负债人生 学习周刊-总第240期-2025年第49周 学习周刊-总第239期-2025年第48周 整理我在静态服务透明代理上的极致求索之路,最后一个你绝想不到 学习周刊-总第238期-2025年第47周 我们输了,但收获颇多 太多了,太多了 学习周刊-总第237期-2025年第46周 学习周刊-总第236期-2025年第45周 学习周刊-总第235期-2025年第44周 二五年国庆二三事 学习周刊-总第234期-2025年第43周 学习周刊-总第233期-2025年第42周 学习周刊-总第232期-2025年第41周 学习周刊-总第231期-2025年第40周 学习周刊-总第230期-2025年第39周 西湖毅行 2025年开源世界逸闻三则 学习周刊-总第229期-2025年第38周 手抄《与妻书》 CNB开发与构建基于docker-cache缓存复用的配置实践心得 学习周刊-总第228期-2025年第37周 父亲善行录 学习周刊-总第227期-2025年第36周 带你认识我之看看我的高中同学录(其二) 学习周刊-总第226期-2025年第35周 带你认识我之看看我的高中同学录(其一) 认识神级MCP工具系列--用anyquery和数据库交互 学习周刊-总第225期-2025年第34周 学习周刊-总第224期-2025年第33周 学习周刊-总第223期-2025年第32周 学习周刊-总第222期-2025年第31周 学习周刊-总第221期-2025年第30周 CNB云原生开发环境届的瑞士军刀,详解qifei项目 vuepress-vdoing主题配置自建不蒜子统计 学习周刊-总第220期-2025年第29周 写在博客发表文章1000篇的节点 从claude cli的体验聊聊最大的敌人是我们自己的成见 学习周刊-总第219期-2025年第28周 学习周刊-总第218期-2025年第27周 学习周刊-总第217期-2025年第26周 理论正确,事实错误 学习周刊-总第216期-2025年第25周 学习周刊-总第215期-2025年第24周 学习周刊-总第214期-2025年第23周 学习周刊-总第213期-2025年第22周 学习周刊-总第212期-2025年第21周 从赵心童世锦赛夺冠聊聊我的斯诺克情缘 学习周刊-总第211期-2025年第20周 记录二五年五一之短暂回归家庭 学习周刊-总第210期-2025年第19周 学习周刊-总第209期-2025年第18周 学习周刊-总第208期-2025年第17周 Go开发实践之Gin框架将前端的dist目录embed到二进制 学习周刊-总第207期-2025年第16周 近期关于cobra库的一些实践心得总结 学习周刊-总第206期-2025年第15周 我的嗜好--嗑瓜子 记大宝参加幼儿园组织的清明烈士陵园扫墓活动 学习周刊-总第205期-2025年第14周 学习周刊-总第204期-2025年第13周 前端开发小笔记--在数组中给字段添加值与删除字段的操作 学习周刊-总第203期-2025年第12周 人生实苦,何以自渡 学习周刊-总第202期-2025年第11周 近期发现的一些优秀的工具提名(一) 学习周刊-总第201期-2025年第10周 学习周刊-总第200期-2025年第09周 记一次女友喝醉使我忍术破功 爱情风波--一次分手又复合的经历 学习周刊-总第199期-2025年第08周 整理我的信息源
使用docker快速部署rancher-2.8.5并投入生产实践
二丫讲梵 · 2024-07-21 · via 二丫讲梵

市面上管理 k8s 多集群的工具非常多,但是真正易于维护,且设计比较优雅好用的并不多,如果你所要管理的集群没有特别多,那么 rancher 是一个不错的选择。

我曾在博客写过 rancher 的部署文档,想想那已经是 2019 年的事情了,彼时采取了高可用的部署方案,较为繁琐,且版本已经落后了太多,今天来简明扼要的写一下通过 docker 快速部署 rancher-2.8.5 以及集群接入,和权限管理等问题,让你通过本文,即可把 rancher 部署且投入到生产实践当中。

# 快速部署

在项目官方的 README 中已经提供了一键部署的命令,如下:

docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher

1

默认拉取最新版本的镜像。

通常我们在生产实践当中,会配置一个自定域名,而不用 IP 访问,通过域名访问时,还需要将证书挂载到容器当中去。

准备证书如下:

$ tree
.
├── ssl
│   ├── eryajf.net_bundle.pem
│   └── eryajf.net.key
└── start.sh

1
2
3
4
5
6

其中 start.sh 的内容为:

docker run -d --restart=unless-stopped \
  -p 80:80 -p 443:443 \
  --name rancher -v /data/rancher/data:/var/lib/rancher \
  --privileged \
  -v /etc/hosts:/etc/hosts \
  -v /data/rancher/ssl/eryajf.net_bundle.pem:/etc/rancher/ssl/cert.pem \
  -v /data/rancher/ssl/eryajf.net.key:/etc/rancher/ssl/key.pem \
  rancher/rancher:v2.8.5 \
  --no-cacerts

1
2
3
4
5
6
7
8
9

指定具体版本的镜像,然后运行即可。

正常运行之后,可以将 rancher.eryajf.net 解析指向该主机的 IP。

申明

原创文章eryajf,未经授权,严禁转载,侵权必究!此乃文中随机水印,敬请读者谅解。

# 权限管理

权限管理可能也是一个比较复杂的部分,但这里我不想把他复杂化,rancher 也支持对接 ldap,但问题是不支持给登陆用户配置默认的对应权限,因此我这里用了一个相对简单的思路来管控权限。

简单来说就是创建一个开发者账号,然后在角色模板中创建一个开发者角色,这个角色拥有 deployment 和 pod 的只读权限,同时拥有查看日志以及 exec 到 pod 的权限,然后只需要在集群的项目中,将该用户添加到项目中并关联该角色即可。这样普通开发者共同使用这个普通账号来登陆 rancher 查看业务应用运行状态就可以了。

角色

点击 用户认证 ---> 角色模板 ---> 选择 项目或命名空间 ---> 点击右上角 创建项目或命名空间的角色

注意对应授予的权限,可按实际需求情况进行增减。

其中的 pods/execpods/log 创建时不会补全,手打即可。

角色创建完成之后,在集群的项目里,将对应的普通用户添加进来,并且关联 devuser 这个角色即可。

这样普通开发者通过 devuser 这个账号登陆 rancher 之后,就拥有了 devuser 这个角色的权限,亦即上边所给到的权限了。