helm 使用

最后发布时间 : 2026-07-10 08:45:36 浏览量 :

执行:

helm repo add traefik https://traefik.github.io/charts

只是添加 Helm 仓库地址到本地 Helm 配置,不会安装 Traefik。Traefik 官方 Helm Chart 仓库就是这个地址。(Traefik)

可以通过下面几个命令查看。


1. 查看已经添加的 Helm repo

helm repo list

输出类似:

NAME        URL
traefik     https://traefik.github.io/charts

说明仓库已经添加。


2. 更新仓库索引

建议执行:

helm repo update

类似:

Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "traefik" chart repository
Update Complete.

3. 查看 Traefik Chart 是否存在

helm search repo traefik

例如:

NAME                CHART VERSION   APP VERSION
traefik/traefik     37.x.x          v3.x.x

其中:

  • traefik/traefik 是安装时使用的名字
  • CHART VERSION 是 Helm Chart 版本
  • APP VERSION 是 Traefik 程序版本

官方安装方式也是:

helm install traefik traefik/traefik

(GitHub)


4. 查看 Chart 详细信息

helm show chart traefik/traefik

例如:

apiVersion: v2
name: traefik
version: 37.0.0
appVersion: v3.5.0
description: A Traefik based Kubernetes ingress controller

5. 查看默认 values.yaml

这个非常重要,安装前一般先看:

helm show values traefik/traefik

或者保存:

helm show values traefik/traefik > values.yaml

然后修改:

deployment:
  replicas: 2

service:
  type: LoadBalancer

安装:

helm install traefik traefik/traefik \
  -f values.yaml \
  -n traefik \
  --create-namespace

6. 查看 Helm 本地缓存

Helm repo 添加后,索引文件一般在:

~/.cache/helm/repository/

例如:

ls ~/.cache/helm/repository/

可能看到:

traefik-index.yaml

里面就是 Chart 列表。


7. 如果想查看 Chart 内部 Kubernetes 模板

下载 Chart:

helm pull traefik/traefik --untar

得到:

traefik/
├── Chart.yaml
├── values.yaml
└── templates/
    ├── deployment.yaml
    ├── service.yaml
    ├── serviceaccount.yaml
    ├── clusterrole.yaml
    ├── clusterrolebinding.yaml
    └── ...

这就是 Helm 最终生成 Kubernetes YAML 的来源。


8. 不安装,只看看最终生成 YAML

非常适合学习:

helm template traefik traefik/traefik

输出类似:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: traefik

---

apiVersion: v1
kind: Service
metadata:
  name: traefik

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
...

也就是说:

helm repo add
        |
        v
添加 Chart 来源

helm search repo
        |
        v
找到 Chart

helm install
        |
        v
读取 templates/*.yaml
        |
        v
渲染 values.yaml
        |
        v
kubectl apply 到 Kubernetes API Server

这也是你前面问的 "https://traefik.github.io/charts 如何解析到 deployment.yaml" 的过程:
Helm 并不是直接访问 deployment.yaml,而是下载 Chart 压缩包,其中包含 templates/deployment.yaml 模板,然后根据 values.yaml 渲染成最终 Kubernetes Manifest。(GitHub)