本文档风哥主要介绍Rancher应用商店与Helm Chart管理实战,包括Rancher数据库应用商店概念、Rancher数据库Helm Chart概念、Rancher数据库Chart架构、Rancher数据库应用商店准备、Rancher数据库应用商店要求、Rancher数据库应用商店规划、Rancher数据库配置应用商店、Rancher数据库部署Chart、Rancher数据库管理Chart、Rancher数据库自定义Chart、Rancher数据库更新Chart、Rancher数据库回滚Chart等内容,风哥教程参考Rancher官方文档应用商店、Helm Chart、Chart管理等内容,适合运维人员在学习和测试中使用,如果要应用于生产环境则需要自行确认。
Part01-基础概念与理论知识
1.1 Rancher数据库应用商店概念
Rancher数据库应用商店是一个用于管理和部署应用程序的集中式平台。应用商店提供了大量的预定义Chart(Helm Chart),用户可以通过应用商店快速部署应用程序。应用商店支持官方Chart、社区Chart和自定义Chart。应用商店可以简化应用程序的部署和管理,提高部署效率,降低部署错误。更多视频教程www.fgedu.net.cn
- 集中式管理:集中管理所有Chart
- 快速部署:快速部署应用程序
- 版本管理:管理Chart版本
- 依赖管理:管理Chart依赖
- 自定义Chart:支持自定义Chart
1.2 Rancher数据库Helm Chart概念
Rancher数据库Helm Chart是Kubernetes应用程序的打包格式。Chart包含了应用程序的所有资源定义、配置文件和依赖关系。Helm Chart使用模板引擎,可以根据不同的环境生成不同的配置。Helm Chart支持版本管理,可以轻松升级和回滚应用程序。学习交流加群风哥微信: itpux-com
- 打包格式:打包应用程序资源
- 模板引擎:支持模板配置
- 版本管理:管理Chart版本
- 依赖管理:管理Chart依赖
- 升级回滚:支持升级和回滚
1.3 Rancher数据库Chart架构
Rancher数据库Chart架构:
┌─────────────────────────────────────────────────────────┐
│ Rancher Server │
│ 192.168.1.100 │
│ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Rancher App Store │ │
│ │ – Official Charts │ │
│ │ – Community Charts │ │
│ │ – Custom Charts │ │
│ │ – Chart Repository │ │
│ └───────────────────────────────────────────────┘ │
└────────────────────┬────────────────────────────────────┘
│
│ Helm CLI
↓
┌─────────────────────────────────────────────────────────┐
│ Kubernetes Cluster │
│ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Helm Release 1 │ │
│ │ – Nginx │ │
│ │ – MySQL │ │
│ │ – Redis │ │
│ └───────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Helm Release 2 │ │
│ │ – WordPress │ │
│ │ – MariaDB │ │
│ └───────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
# 架构说明
1. Rancher Server:提供应用商店管理界面
2. Rancher App Store:集中管理所有Chart
3. Helm CLI:用于部署和管理Chart
4. Kubernetes Cluster:运行应用程序
5. Helm Release:部署的Chart实例
Part02-生产环境规划与建议
2.1 Rancher数据库应用商店准备
Rancher数据库应用商店准备:
# 1. Rancher Server准备
– Rancher Server已部署
– Rancher Server可访问
– Rancher Server配置正确
# 2. Helm CLI准备
– 安装Helm CLI
– 配置Helm CLI
– 测试Helm CLI
# 3. Chart仓库准备
– 添加官方Chart仓库
– 添加社区Chart仓库
– 添加自定义Chart仓库
# 4. 应用需求分析
– 确定应用程序类型
– 确定应用程序版本
– 确定应用程序配置
– 确定应用程序依赖
# 5. 部署环境准备
– 准备命名空间
– 准备存储类
– 准备网络策略
– 准备资源配额
2.2 Rancher数据库应用商店要求
Rancher数据库应用商店要求:
# Helm CLI要求
– Helm版本:>= v3.0.0
– Kubeconfig:正确配置
– 权限:具有部署权限
# Chart仓库要求
– 仓库地址:可访问
– 仓库认证:正确配置
– 仓库同步:定期同步
# Chart要求
– Chart版本:明确具体
– Chart依赖:明确具体
– Chart配置:明确具体
– Chart测试:经过测试
# 部署环境要求
– 命名空间:已创建
– 存储类:已配置
– 网络策略:已配置
– 资源配额:已配置
2.3 Rancher数据库应用商店规划
Rancher数据库应用商店规划:
# Chart仓库规划
官方仓库:https://charts.rancher.io
社区仓库:https://charts.helm.sh/stable
自定义仓库:http://harbor.fgedu.net.cn/chartrepo/fgedu
# 应用程序规划
应用1:Nginx(Web服务器)
应用2:MySQL(数据库)
应用3:Redis(缓存)
应用4:WordPress(CMS)
# 部署环境规划
开发环境:fgedu-dev
测试环境:fgedu-test
生产环境:fgedu-prod
# 资源规划
Nginx:
CPU:500m
内存:512Mi
存储:10Gi
MySQL:
CPU:1000m
内存:2Gi
存储:100Gi
Redis:
CPU:500m
内存:1Gi
存储:20Gi
WordPress:
CPU:1000m
内存:1Gi
存储:50Gi
Part03-生产环境项目实施方案
3.1 Rancher数据库配置应用商店
3.1.1 Rancher数据库通过Web界面配置应用商店
# 步骤1:登录Rancher管理界面
# 步骤2:点击”集群” – 选择集群 – 点击”工具” – “Charts”
# 步骤3:点击”添加仓库”按钮
# 步骤4:填写仓库信息:
# 仓库名称:fgedu-repo
# 仓库URL:http://harbor.fgedu.net.cn/chartrepo/fgedu
# 仓库类型:Helm
# 步骤5:点击”创建”按钮
# 通过Helm CLI配置应用商店
[root@rancher ~]# helm repo add rancher-stable https://charts.rancher.io
“rancher-stable” has been added to your repositories
[root@rancher ~]# helm repo add stable https://charts.helm.sh/stable
“stable” has been added to your repositories
[root@rancher ~]# helm repo add fgedu-repo http://harbor.fgedu.net.cn/chartrepo/fgedu \
–username admin \
–password Harbor@123456
“fgedu-repo” has been added to your repositories
# 查看仓库列表
[root@rancher ~]# helm repo list
NAME URL
rancher-stable https://charts.rancher.io
stable https://charts.helm.sh/stable
fgedu-repo http://harbor.fgedu.net.cn/chartrepo/fgedu
# 更新仓库
[root@rancher ~]# helm repo update
Hang tight while we grab the latest from your chart repositories…
…Successfully got an update from the “rancher-stable” chart repository
…Successfully got an update from the “stable” chart repository
…Successfully got an update from the “fgedu-repo” chart repository
Update Complete. ⎈Happy Helming!⎈
# 搜索Chart
[root@rancher ~]# helm search repo nginx
NAME CHART VERSION APP VERSION DESCRIPTION
rancher-stable/nginx 13.2.3 1.25.3 NGINX Open Source is a web server that can also …
stable/nginx 13.2.3 1.25.3 NGINX Open Source is a web server that can also …
fgedu-repo/nginx 1.0.0 1.25.3 NGINX Web Server
3.2 Rancher数据库部署Chart
3.2.1 Rancher数据库通过Web界面部署Chart
# 步骤1:登录Rancher管理界面
# 步骤2:点击”集群” – 选择集群 – 点击”工具” – “Charts”
# 步骤3:选择Chart:nginx
# 步骤4:点击”安装”按钮
# 步骤5:填写Chart配置:
# Release名称:fgedu-nginx
# 命名空间:fgedu-dev
# 镜像:nginx:1.25.3
# 副本数:3
# Service类型:LoadBalancer
# 步骤6:点击”安装”按钮
# 通过Helm CLI部署Chart
[root@rancher ~]# helm install fgedu-nginx rancher-stable/nginx \
–namespace fgedu-dev \
–set image.tag=1.25.3 \
–set replicaCount=3 \
–set service.type=LoadBalancer
NAME: fgedu-nginx
LAST DEPLOYED: Fri Apr 10 10:00:00 2026
NAMESPACE: fgedu-dev
STATUS: deployed
REVISION: 1
NOTES:
The NGINX Ingress controller has been installed.
# 查看Release列表
[root@rancher ~]# helm list -n fgedu-dev
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
fgedu-nginx fgedu-dev 1 2026-04-10 10:00:00 +0800 CST deployed nginx-13.2.3 1.25.3
# 查看Release状态
[root@rancher ~]# helm status fgedu-nginx -n fgedu-dev
NAME: fgedu-nginx
LAST DEPLOYED: Fri Apr 10 10:00:00 2026
NAMESPACE: fgedu-dev
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The NGINX Ingress controller has been installed.
# 查看Pod状态
[root@rancher ~]# kubectl get pods -n fgedu-dev -l app.kubernetes.io/name=nginx
NAME READY STATUS RESTARTS AGE
fgedu-nginx-1234567890-abcde 1/1 Running 0 1m
fgedu-nginx-1234567890-fghij 1/1 Running 0 1m
fgedu-nginx-1234567890-klmno 1/1 Running 0 1m
# 查看Service状态
[root@rancher ~]# kubectl get svc -n fgedu-dev fgedu-nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
fgedu-nginx LoadBalancer 10.43.123.45 192.168.1.200 80:31234/TCP 1m
3.3 Rancher数据库管理Chart
3.3.1 Rancher数据库查看Chart信息
# 查看Chart详细信息
[root@rancher ~]# helm show chart rancher-stable/nginx
apiVersion: v2
name: nginx
description: NGINX Open Source is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache.
type: application
version: 13.2.3
appVersion: “1.25.3”
keywords:
– nginx
– http
– web
– reverse proxy
home: https://www.nginx.com/
icon: https://bitnami.com/assets/stacks/nginx/img/nginx-stack-220×234.png
sources:
– https://github.com/bitnami/bitnami-docker-nginx
maintainers:
– name: Bitnami
email: containers@bitnami.com
# 查看Chart配置
[root@rancher ~]# helm show values rancher-stable/nginx
# Default values for nginx
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
registry: docker.io
repository: bitnami/nginx
tag: 1.25.3
pullPolicy: IfNotPresent
service:
type: LoadBalancer
port: 80
annotations: {}
ingress:
enabled: false
className: “”
annotations: {}
hosts:
– host: chart-example.local
paths:
– path: /
pathType: Prefix
tls: []
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 250m
memory: 256Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80
# 查看已安装的Chart
[root@rancher ~]# helm list -A
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
fgedu-nginx fgedu-dev 1 2026-04-10 10:00:00 +0800 CST deployed nginx-13.2.3 1.25.3
Part04-生产案例与实战讲解
4.1 Rancher数据库自定义Chart
4.1.1 Rancher数据库创建自定义Chart
[root@rancher ~]# mkdir -p fgedu-chart/{templates,charts}
[root@rancher ~]# cd fgedu-chart
# 创建Chart.yaml文件 # 升级Chart Release “fgedu-nginx” has been upgraded. Happy Helming! # 查看升级后的Release # 查看Pod状态 # 查看Release历史 # 回滚到版本1 # 查看回滚后的Release # 查看Pod状态 # 查看Release历史 Rancher数据库应用商店最佳实践: Rancher数据库应用商店问题排查: # 问题1:Chart部署失败 # 问题2:Chart升级失败 # 问题3:Chart回滚失败 # 问题4:Chart仓库无法访问 Rancher数据库应用商店维护: # 1. 定期检查 # 2. 定期更新 # 3. 定期备份 # 4. 定期清理 # 5. 定期审计 本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
[root@rancher fgedu-chart]# cat > Chart.yaml <4.2 Rancher数据库更新Chart
4.2.1 Rancher数据库升级Chart
# 查看当前Release
[root@rancher ~]# helm list -n fgedu-dev
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
fgedu-nginx fgedu-dev 1 2026-04-10 10:00:00 +0800 CST deployed nginx-13.2.3 1.25.3
[root@rancher ~]# helm upgrade fgedu-nginx rancher-stable/nginx \
–namespace fgedu-dev \
–set image.tag=1.25.4 \
–set replicaCount=5
NAME: fgedu-nginx
LAST DEPLOYED: Fri Apr 10 10:05:00 2026
NAMESPACE: fgedu-dev
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
The NGINX Ingress controller has been installed.
[root@rancher ~]# helm list -n fgedu-dev
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
fgedu-nginx fgedu-dev 2 2026-04-10 10:05:00 +0800 CST deployed nginx-13.2.3 1.25.4
[root@rancher ~]# kubectl get pods -n fgedu-dev -l app.kubernetes.io/name=nginx
NAME READY STATUS RESTARTS AGE
fgedu-nginx-1234567890-abcde 1/1 Running 0 5m
fgedu-nginx-1234567890-fghij 1/1 Running 0 5m
fgedu-nginx-1234567890-klmno 1/1 Running 0 5m
fgedu-nginx-2345678901-abcde 1/1 Running 0 1m
fgedu-nginx-2345678901-fghij 1/1 Running 0 1m
[root@rancher ~]# helm history fgedu-nginx -n fgedu-dev
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Apr 10 10:00:00 2026 superseded nginx-13.2.3 1.25.3 Install complete
2 Fri Apr 10 10:05:00 2026 deployed nginx-13.2.3 1.25.4 Upgrade complete
4.3 Rancher数据库回滚Chart
4.3.1 Rancher数据库回滚Release
# 查看Release历史
[root@rancher ~]# helm history fgedu-nginx -n fgedu-dev
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Apr 10 10:00:00 2026 superseded nginx-13.2.3 1.25.3 Install complete
2 Fri Apr 10 10:05:00 2026 deployed nginx-13.2.3 1.25.4 Upgrade complete
[root@rancher ~]# helm rollback fgedu-nginx 1 -n fgedu-dev
Rollback was a success! Happy Helming!
[root@rancher ~]# helm list -n fgedu-dev
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
fgedu-nginx fgedu-dev 3 2026-04-10 10:10:00 +0800 CST deployed nginx-13.2.3 1.25.3
[root@rancher ~]# kubectl get pods -n fgedu-dev -l app.kubernetes.io/name=nginx
NAME READY STATUS RESTARTS AGE
fgedu-nginx-1234567890-abcde 1/1 Running 0 10m
fgedu-nginx-1234567890-fghij 1/1 Running 0 10m
fgedu-nginx-1234567890-klmno 1/1 Running 0 10m
[root@rancher ~]# helm history fgedu-nginx -n fgedu-dev
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Apr 10 10:00:00 2026 superseded nginx-13.2.3 1.25.3 Install complete
2 Fri Apr 10 10:05:00 2026 superseded nginx-13.2.3 1.25.4 Upgrade complete
3 Fri Apr 10 10:10:00 2026 deployed nginx-13.2.3 1.25.3 Rollback to 1
Part05-风哥经验总结与分享
5.1 Rancher数据库应用商店最佳实践
5.2 Rancher数据库应用商店问题排查
# 现象:Chart部署时提示错误
# 原因:配置错误、资源不足、依赖问题
# 解决:
[root@rancher ~]# helm status fgedu-nginx -n fgedu-dev
[root@rancher ~]# helm get values fgedu-nginx -n fgedu-dev
[root@rancher ~]# kubectl get pods -n fgedu-dev
[root@rancher ~]# kubectl describe pod
[root@rancher ~]# kubectl logs
# 现象:Chart升级时提示错误
# 原因:配置冲突、版本不兼容、依赖问题
# 解决:
[root@rancher ~]# helm history fgedu-nginx -n fgedu-dev
[root@rancher ~]# helm get values fgedu-nginx -n fgedu-dev
[root@rancher ~]# helm diff upgrade fgedu-nginx rancher-stable/nginx -n fgedu-dev
[root@rancher ~]# helm upgrade fgedu-nginx rancher-stable/nginx -n fgedu-dev –dry-run
# 现象:Chart回滚时提示错误
# 原因:历史版本不存在、配置冲突
# 解决:
[root@rancher ~]# helm history fgedu-nginx -n fgedu-dev
[root@rancher ~]# helm rollback fgedu-nginx
[root@rancher ~]# helm rollback fgedu-nginx
# 现象:无法添加或更新Chart仓库
# 原因:网络不通、认证失败、仓库地址错误
# 解决:
[root@rancher ~]# ping
[root@rancher ~]# curl -I
[root@rancher ~]# helm repo remove
[root@rancher ~]# helm repo add 5.3 Rancher数据库应用商店维护
– 检查Chart仓库状态
– 检查Release状态
– 检查Pod状态
– 检查资源使用情况
– 更新Chart版本
– 更新Chart配置
– 更新Helm CLI
– 更新Chart仓库
– 备份Release配置
– 备份Chart配置
– 备份Chart仓库
– 备份应用数据
– 清理无用Release
– 清理无用Chart
– 清理无用镜像
– 清理过期日志
– 审计Chart配置
– 审计Release配置
– 审计操作日志
– 审计资源使用情况
