基于Helm管理 Kubernetes 应用的安装和升级使用教程
·
helm有点类似于Linux的yum,apt工具,帮助我们管理K8S集群的资源清单。下面来开始学习使用吧(本次环境是基于Ubuntu22.04系统部署的二进制k8s集群)
一 部署
1. 下载helm
wget https://get.helm.sh/helm-v3.19.4-linux-amd64.tar.gz
2. 解压helm软件包
[root@master01 ~]# tar xf helm-v3.19.4-linux-amd64.tar.gz -C /usr/local/bin/ linux-amd64/helm --strip-components=1
[root@master01 ~]# ll /usr/local/bin/helm
-rwxr-xr-x 1 1001 1001 60182712 Dec 13 05:40 /usr/local/bin/helm*
3. 查看helm的版本
[root@master01 ~]# helm version
version.BuildInfo{Version:"v3.19.4", GitCommit:"7cfb6e486dac026202556836bb910c37d847793e", GitTreeState:"clean", GoVersion:"go1.24.11"}
4. 配置helm的自动补全功能
[root@master01 ~]# helm completion bash > /etc/bash_completion.d/helm
[root@master01 ~]# echo 'source /etc/bash_completion.d/helm' >> ~/.bashrc
二 Chart基本管理
1. 创建Chart
[root@master01 kubernetes]# mkdir -pv /opt/k8s/add-ons/helm-charts
mkdir: created directory '/opt/k8s'
mkdir: created directory '/opt/k8s/add-ons'
mkdir: created directory '/opt/k8s/add-ons/helm-charts'
[root@master01 kubernetes]# cd /opt/k8s/add-ons/helm-charts
[root@master01 helm-charts]#
[root@master01 helm-charts]# apt -y install tree
[root@master01 helm-charts]# helm create whelm-linux
Creating whelm-linux
[root@master01 helm-charts]# ls
whelm-linux
2. 查看Chart结构
[root@master01 helm-charts]# tree whelm-linux
whelm-linux
// Chart 元信息配置(名称、版本、应用版本、依赖等)
├── Chart.yaml
// 存放依赖的子 Chart(本地依赖,非通过 repo 拉取的依赖)
├── charts
// 核心模板目录,存放 K8s 资源模板(Deployment、Service 等),支持 Go 模板语法
├── templates
// 部署后显示的使用说明(如访问地址、命令提示)
│ ├── NOTES.txt
// 自定义模板函数(如标签生成、名称拼接)
│ ├── _helpers.tpl
// Deployment 资源模板(应用部署核心)
│ ├── deployment.yaml
// HorizontalPodAutoscaler 模板(弹性伸缩)
│ ├── hpa.yaml
// HTTPRoute 模板(适配 Kubernetes Gateway API,替代 Ingress 的新方案)
│ ├── httproute.yaml
// Ingress 模板(域名访问、反向代理)
│ ├── ingress.yaml
// Service 模板(Pod 访问入口)
│ ├── service.yaml
// ServiceAccount 模板(Pod 权限标识)
│ ├── serviceaccount.yaml
// 测试模板(部署后验证应用可用性)
│ └── tests
│ └── test-connection.yaml
// 配置参数文件(模板的变量来源)
└── values.yaml
3 directories, 11 files
[root@master01 helm-charts]#
3. 修改默认的values.yaml
[root@master01 helm-charts]# egrep "repository:|tag:" whelm-linux/values.yaml
repository: nginx
tag: ""
[root@master01 helm-charts]# sed -i "/repository\:/s#nginx#testgame#" whelm-linux/values.yaml
[root@master01 helm-charts]# sed -ri '/tag\:/s#tag: ""#tag: v0.1#' whelm-linux/values.yaml
egrep "repository:|tag:" whelm-linux/values.yaml
repository: testgame
tag: v0.1
记得修改监控端口我的是8090
记得检查下配置文件
/opt/k8s/add-ons/helm-charts/whelm-linux
[root@master01 whelm-linux]# cat values.yaml
#Default values for whelm-linux.
replicaCount: 2
image:
repository: testgame
pullPolicy: Never
tag: v0.1
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
create: true
automount: true
annotations: {}
name: ""
podAnnotations: {}
podLabels: {}
podSecurityContext: {}
securityContext: {}
service:
type: ClusterIP
port: 8090
targetPort: 8090
ingress:
enabled: false
className: ""
annotations: {}
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
httpRoute:
enabled: false
annotations: {}
parentRefs:
- name: gateway
sectionName: http
hostnames:
- chart-example.local
rules:
- matches:
- path:
type: PathPrefix
value: /headers
resources: {}
livenessProbe: {}
readinessProbe: {}
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
volumes: []
volumeMounts: []
nodeSelector: {}
tolerations: []
affinity: {}
4.基于Chart安装服务发行Release
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME SECRETS AGE
serviceaccount/default 0 16d
[root@master01 helm-charts]# helm -n kube-public install hgame whelm-linux
NAME: hgame
LAST DEPLOYED: Sun Jan 25 19:48:32 2026
NAMESPACE: kube-public
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace kube-public -l "app.kubernetes.io/name=whelm-linux,app.kubernetes.io/instance=hgame" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace kube-public $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace kube-public port-forward $POD_NAME 8080:$CONTAINER_PORT
5. 查看Release列表并查看K8S的资源变化
[root@master01 helm-charts]# helm list -n kube-public
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hgame kube-public 1 2026-01-25 19:48:32.254750014 +0800 CST deployed whelm-linux-0.1.0 1.16.0
[root@master01 whelm-linux]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 2/2 2 2 44m whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.227.226 <none> 8090/TCP 44m app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 44m
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-h7nfq 1/1 Running 0 4m59s 10.100.30.87 worker02 <none> <none>
pod/hgame-whelm-linux-78b7c578b-wc4gt 1/1 Running 0 4m57s 10.100.5.36 worker01 <none> <none>
6. 测试访问
[root@master01 whelm-linux]# 10.100.30.87:8090
10.100.30.87:8090: command not found
[root@master01 whelm-linux]# curl 10.100.30.87:8090
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>经典小游戏合集 - 点击开始游玩</title>
...
<div class="game-list">
<div class="game-item"><a href="/html/zhiwuVSjiangshi/">植物VS僵尸</a></div>
</div>
</body>
</html>
[root@master01 whelm-linux]# curl 10.100.5.36:8090
<!DOCTYPE html>
<html lang="zh-CN">
<head>
...
<div class="game-list">
<div class="game-item"><a href="/html/zhiwuVSjiangshi/">植物VS僵尸</a></div>
</div>
</body>
</html>
[root@master01 whelm-linux]# curl 10.200.227.226:8090
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>经典小游戏合集 - 点击开始游玩</title>
<style>
* {margin:0;padding:0;box-sizing:border-box;}
body {background:#1e1e1e;padding:20px;font-family:Arial, "微软雅黑", sans-serif;}
h1 {text-align:center;color:#fff;margin-bottom:30px;font-size:28px;}
.game-list {width:100%;max-width:1200px;margin:0 auto;display:flex;flex-wrap:wrap;justify-content:center;gap:15px;}
.game-item {width:160px;height:60px;line-height:60px;background:#2d7dff;text-align:center;border-radius:8px;}
.game-item a {display:block;width:100%;height:100%;color:#fff;text-decoration:none;font-size:16px;font-weight:bold;}
.game-item:hover {background:#1a66e0;transform:scale(1.03);transition:all 0.2s;}
</style>
</head>
<body>
...
<div class="game-list">
<div class="game-item"><a href="/html/zhiwuVSjiangshi/">植物VS僵尸</a></div>
</div>
</body>
</html>
7. 卸载服务
[root@master01 whelm-linux]# helm list -n kube-public
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hgame kube-public 1 2026-01-25 20:28:29.655814384 +0800 CST deployed whelm-linux-0.1.0 1.16.0
[root@master01 helm-charts]# ls
whelm-linux
[root@master01 helm-charts]# helm -n kube-public uninstall hgame
release "hgame" uninstalled
[root@master01 helm-charts]# helm list -n kube-public
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME SECRETS AGE
serviceaccount/default 0 16d
三 helm的两种升级方式案例
1. 安装旧的服务
[root@master01 helm-charts]# helm -n kube-public install hgame whelm-linux
NAME: hgame
LAST DEPLOYED: Sun Jan 25 20:54:43 2026
NAMESPACE: kube-public
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace kube-public -l "app.kubernetes.io/name=whelm-linux,app.kubernetes.io/instance=hgame" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace kube-public $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace kube-public port-forward $POD_NAME 8080:$CONTAINER_PORT
[root@master01 helm-charts]#
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 2/2 2 2 28s whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.168.6 <none> 8090/TCP 28s app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 28s
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-5s822 1/1 Running 0 28s 10.100.30.88 worker02 <none> <none>
pod/hgame-whelm-linux-78b7c578b-hfj7d 1/1 Running 0 28s 10.100.5.37 worker01 <none> <none>
2.修改要升级的相关参数
随便改需要升级什么改什么 这里只改了版本和pod数量
[root@master01 helm-charts]# egrep "replicaCount|tag:" whelm-linux/values.yaml
replicaCount: 2
tag: v0.1
[root@master01 helm-charts]# sed -i '/replicaCount/s#2#3#' whelm-linux/values.yaml
[root@master01 helm-charts]# sed -i "/tag:/s#v0.1#v0.2#" whelm-linux/values.yaml
[root@master01 helm-charts]# egrep "replicaCount|tag:" whelm-linux/values.yaml
replicaCount: 3
tag: v0.2
3. 基于文件方式升级
[root@master01 helm-charts]# helm -n kube-public upgrade hgame -f whelm-linux/values.yaml whelm-linux
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 3/3 3 3 2m47s whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.30.232 <none> 8090/TCP 2m47s app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 2m47s
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-p4xdk 1/1 Running 0 2m47s 10.100.235.12 master03 <none> <none>
pod/hgame-whelm-linux-78b7c578b-pb55g 1/1 Running 0 2m47s 10.100.30.89 worker02 <none> <none>
pod/hgame-whelm-linux-78b7c578b-ttpqh 1/1 Running 0 2m47s 10.100.5.39 worker01 <none> <none>
curl 10.200.30.232:8090
<!DOCTYPE html>
<html lang="zh-CN">
...
</html>
4.基于环境变量方式升级
[root@master01 helm-charts]# sed -i '/replicaCount/s#3#1#' whelm-linux/values.yaml
[root@master01 helm-charts]# egrep "replicaCount|tag:" whelm-linux/values.yaml
replicaCount: 1
tag: v0.1
[root@master01 helm-charts]# helm -n kube-public upgrade hgame --set replicaCount=2,image.tag=v0.1 whelm-linux
Release "hgame" has been upgraded. Happy Helming!
NAME: hgame
LAST DEPLOYED: Sun Jan 25 21:30:16 2026
NAMESPACE: kube-public
STATUS: deployed
REVISION: 3
NOTES:
1. Get the application URL by running these commands:
export POD_NAME=$(kubectl get pods --namespace kube-public -l "app.kubernetes.io/name=whelm-linux,app.kubernetes.io/instance=hgame" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace kube-public $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace kube-public port-forward $POD_NAME 8080:$CONTAINER_PORT
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 2/2 2 2 11m whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.30.232 <none> 8090/TCP 11m app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 11m
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-jr8bj 1/1 Running 0 11s 10.100.30.90 worker02 <none> <none>
pod/hgame-whelm-linux-78b7c578b-ttpqh 1/1 Running 0 11m 10.100.5.39 worker01 <none> <none>
最后记得删除
helm -n kube-public uninstall hgame
四. helm的回滚
1. 查看RELEASE历史版本
[root@master01 helm-charts]# helm list -n kube-public
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hgame kube-public 3 2026-01-25 21:30:16.736625573 +0800 CST deployed whelm-linux-0.1.0 1.16.0
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 deployed whelm-linux-0.1.0 1.16.0 Upgrade complete
2.回滚到上一个版本
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 2/2 2 2 11m whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.30.232 <none> 8090/TCP 11m app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 11m
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-jr8bj 1/1 Running 0 11s 10.100.30.90 worker02 <none> <none>
pod/hgame-whelm-linux-78b7c578b-ttpqh 1/1 Running 0 11m 10.100.5.39 worker01 <none> <none>
[root@master01 helm-charts]# helm list -n kube-public
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hgame kube-public 3 2026-01-25 21:30:16.736625573 +0800 CST deployed whelm-linux-0.1.0 1.16.0
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 deployed whelm-linux-0.1.0 1.16.0 Upgrade complete
[root@master01 helm-charts]# helm -n kube-public rollback hgame
Rollback was a success! Happy Helming!
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
4 Sun Jan 25 21:37:04 2026 deployed whelm-linux-0.1.0 1.16.0 Rollback to 2
[root@master01 helm-charts]# helm list -n kube-public
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hgame kube-public 4 2026-01-25 21:37:04.206695223 +0800 CST deployed whelm-linux-0.1.0 1.16.0
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 1/1 1 1 18m whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.30.232 <none> 8090/TCP 18m app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 18m
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-ttpqh 1/1 Running 0 18m 10.100.5.39 worker01 <none> <none>
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
4 Sun Jan 25 21:37:04 2026 deployed whelm-linux-0.1.0 1.16.0 Rollback to 2
3. 再次回滚到上一个版本并验证结果
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
4 Sun Jan 25 21:37:04 2026 deployed whelm-linux-0.1.0 1.16.0 Rollback to 2
[root@master01 helm-charts]# helm -n kube-public rollback hgame
Rollback was a success! Happy Helming!
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
4 Sun Jan 25 21:37:04 2026 superseded whelm-linux-0.1.0 1.16.0 Rollback to 2
5 Sun Jan 25 21:39:48 2026 deployed whelm-linux-0.1.0 1.16.0 Rollback to 3
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 2/2 2 2 21m whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.30.232 <none> 8090/TCP 21m app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 21m
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-ttpqh 1/1 Running 0 21m 10.100.5.39 worker01 <none> <none>
pod/hgame-whelm-linux-78b7c578b-ttw7t 1/1 Running 0 23s 10.100.30.91 worker02 <none> <none>
4. 回滚到指定版本
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
4 Sun Jan 25 21:37:04 2026 superseded whelm-linux-0.1.0 1.16.0 Rollback to 2
5 Sun Jan 25 21:39:48 2026 deployed whelm-linux-0.1.0 1.16.0 Rollback to 3
[root@master01 helm-charts]# helm -n kube-public rollback hgame 1
Rollback was a success! Happy Helming!
[root@master01 helm-charts]# helm -n kube-public history hgame
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Sun Jan 25 21:18:43 2026 superseded whelm-linux-0.1.0 1.16.0 Install complete
2 Sun Jan 25 21:24:35 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
3 Sun Jan 25 21:30:16 2026 superseded whelm-linux-0.1.0 1.16.0 Upgrade complete
4 Sun Jan 25 21:37:04 2026 superseded whelm-linux-0.1.0 1.16.0 Rollback to 2
5 Sun Jan 25 21:39:48 2026 superseded whelm-linux-0.1.0 1.16.0 Rollback to 3
6 Sun Jan 25 21:47:02 2026 deployed whelm-linux-0.1.0 1.16.0 Rollback to 1
[root@master01 helm-charts]# kubectl get deploy,hpa,svc,sa,po -o wide -n kube-public
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hgame-whelm-linux 3/3 3 3 28m whelm-linux testgame:v0.1 app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hgame-whelm-linux ClusterIP 10.200.30.232 <none> 8090/TCP 28m app.kubernetes.io/instance=hgame,app.kubernetes.io/name=whelm-linux
NAME SECRETS AGE
serviceaccount/default 0 16d
serviceaccount/hgame-whelm-linux 0 28m
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hgame-whelm-linux-78b7c578b-kqff2 1/1 Running 0 38s 10.100.235.13 master03 <none> <none>
pod/hgame-whelm-linux-78b7c578b-ttpqh 1/1 Running 0 28m 10.100.5.39 worker01 <none> <none>
pod/hgame-whelm-linux-78b7c578b-ttw7t 1/1 Running 0 7m52s 10.100.30.91 worker02 <none> <none>
五. helm的公有仓库管理
1. 主流的Chart仓库推荐
互联网公开Chart仓库,可以直接使用他们制作好的Chart包:
微软仓库:
https://mirror.azure.cn/kubernetes/charts/ (国内)
https://kubernetes-charts.azure.com (国际)
阿里云仓库:
https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
2. 公有仓库管理
//添加
[root@master01 helm-charts]# helm repo add azure https://mirror.azure.cn/kubernetes/charts/
"azure" has been added to your repositories
[root@master01 helm-charts]# helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
"aliyun" has been added to your repositories
[root@master01 helm-charts]#
//查看本地仓库列表
[root@master01 helm-charts]# helm repo list
NAME URL
azure https://mirror.azure.cn/kubernetes/charts/
aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
// 更新本地仓库信息
[root@master01 helm-charts]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "aliyun" chart repository
...Successfully got an update from the "azure" chart repository
Update Complete. ⎈Happy Helming!⎈
[root@master01 helm-charts]#
// 搜索"Chart"
[root@master01 helm-charts]# helm search repo Chart
NAME CHART VERSION APP VERSION DESCRIPTION
azure/chartmuseum 2.14.2 0.12.0 DEPRECATED Host your own Helm Chart Repository
aliyun/aerospike 0.1.7 v3.14.1.2 A Helm chart for Aerospike in Kubernetes
aliyun/cert-manager 0.2.2 0.2.3 A Helm chart for cert-manager
aliyun/docker-registry 1.0.3 2.6.2 A Helm chart for Docker Registry
aliyun/etcd-operator 0.7.0 0.7.0
...
[root@master01 helm-charts]#
// 显示所有的版本信息列表
[root@master01 game]# helm search repo Chart -l
NAME CHART VERSION APP VERSION DESCRIPTION
azure/chartmuseum 2.14.2 0.12.0 DEPRECATED Host your own Helm Chart Repository
azure/chartmuseum 2.14.1 0.12.0 Host your own Helm Chart Repository
azure/chartmuseum 2.14.0 0.12.0 Host your own Helm Chart Repository
azure/chartmuseum 2.13.3 0.12.0 Host your own Helm Chart Repository
azure/chartmuseum 2.13.2 0.12.0 Host your own Helm Chart Repository
azure/chartmuseum 2.13.1 0.12.0 Host your own Helm Chart Repository
azure/chartmuseum 2.13.0 0.12.0 Host your own Helm Chart Repository
.....
// 查看Chart的详细信息
[root@master01 game]# helm show chart aliyun/elasticsearch-exporter 指定版本加 --version 0.1.2
apiVersion: v1
appVersion: 1.0.2
description: Elasticsearch stats exporter for Prometheus
keywords:
- metrics
- elasticsearch
- monitoring
maintainers:
- email: sven.mueller@commercetools.com
name: svenmueller
name: elasticsearch-exporter
sources:
- https://github.com/justwatchcom/elasticsearch_exporter
version: 0.1.2
// 拉取Chart
helm pull aliyun/elasticsearch-exporter 指定版本加 --version 0.1.2
// 删除第三方仓库
[root@master01 helm-charts]# helm repo list
NAME URL
azure https://mirror.azure.cn/kubernetes/charts/
aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
// 删除指定名称即可
helm repo remove aliyun azure
官方文档:
https://helm.sh/zh/
官方地址:
https://helm.sh/docs/intro/install/
更多推荐




所有评论(0)