1. 获取 Chart 定义
使用 helm show chart
命令可以查看 Helm Chart 的基本信息,包括 Chart 名称、版本、支持的 Kubernetes API 版本、依赖关系等。
$ helm show chart [chart]
也可以使用 helm inspect chart
实现相同功能:
$ helm inspect chart [chart]
示例:查看 Bitnami 提供的 Apache Chart 定义:
$ helm show chart oci://registry-1.docker.io/bitnamicharts/apache
Pulled: registry-1.docker.io/bitnamicharts/apache:10.2.4
Digest: sha256:edfd294077eb062cdf37c1b3c23997b8f5482d6c3bf7c0d0ed8755e51c48eb03
annotations:
category: Infrastructure
images: |
- name: apache-exporter
image: docker.io/bitnami/apache-exporter:1.0.3-debian-11-r2
- name: apache
image: docker.io/bitnami/apache:2.4.58-debian-11-r3
- name: git
image: docker.io/bitnami/git:2.43.0-debian-11-r0
licenses: Apache-2.0
apiVersion: v2
...truncated...
name: apache
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/apache
version: 10.2.4
如果 Chart 来自私有仓库,可以使用 --username
和 --password
指定凭证:
$ helm show chart my-chart --repo https://myrepo.com/charts --username user --password pass
默认显示最新版本,如需指定版本可使用 --version
:
$ helm show chart oci://registry-1.docker.io/bitnamicharts/apache --version 10.0.0
✅ 小贴士:使用 --version
可以快速查看历史版本的 Chart 定义,方便版本回溯。
2. 获取 Chart 的 CRD 信息
CRD(Custom Resource Definition)是 Helm Chart 中用于定义自定义资源的文件。我们可以使用 helm show crds
查看这些定义。
示例:我们为 Grafana Chart 添加一个自定义 Deployment CRD:
$ git clone --depth=1 https://github.com/grafana/helm-charts
$ cd helm-charts
$ git sparse-checkout set charts/grafana
$ cd charts/grafana/
$ mkdir crds
$ cd crds
创建 app.yml
:
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: cms
name: app-deployment
labels:
app: app
spec:
replicas: 1
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: httpd
ports:
- containerPort: 80
使用 helm show crds
查看:
$ helm show crds /home/baeldung/helm-charts/charts/grafana/
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: cms
name: app-deployment
labels:
app: app
...truncated...
spec:
containers:
- name: app
image: httpd
ports:
- containerPort: 80
可以看到输出与 app.yml
内容一致。
⚠️ 注意:helm show crds
仅展示 crds/
目录下的文件内容,不会进行实际安装或验证。
3. 获取 Chart 的 Values
使用 helm show values
可以查看 Chart 的默认配置项,即 values.yaml
文件内容。
$ helm show values [chart]
示例:查看 Bitnami Apache Chart 的 values:
$ helm show values oci://registry-1.docker.io/bitnamicharts/apache
Pulled: registry-1.docker.io/bitnamicharts/apache:10.2.4
Digest: sha256:edfd294077eb062cdf37c1b3c23997b8f5482d6c3bf7c0d0ed8755e51c48eb03
...truncated...
global:
imageRegistry: ""
imagePullSecrets: []
storageClass: ""
image:
registry: docker.io
repository: bitnami/apache
tag: 2.4.58-debian-11-r3
digest: ""
...truncated...
和其它命令一样,helm show values
也支持 --repo
、--version
、--username
和 --password
参数。
4. 获取 Chart 的 README
每个 Helm Chart 通常包含一个 README 文件,用于说明安装方法、配置选项和注意事项。使用 helm show readme
可以查看这些说明。
示例:查看 Bitnami Apache Chart 的 README:
$ helm show readme oci://registry-1.docker.io/bitnamicharts/apache
Pulled: registry-1.docker.io/bitnamicharts/apache:10.2.4
Digest: sha256:edfd294077eb062cdf37c1b3c23997b8f5482d6c3bf7c0d0ed8755e51c48eb03
<!--- app-name: Apache -->
# Bitnami package for Apache
Apache HTTP Server is an open-source HTTP server. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
[Overview of Apache](https://httpd.apache.org/)
Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.
...truncated...
查看远程未安装的 Grafana Chart 的 README:
$ helm show readme grafana --repo https://grafana.github.io/helm-charts
# Grafana Helm Chart
* Installs the web dashboarding system [Grafana](http://grafana.org/)
## Get Repo Info
```console
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
See helm repo for command documentation.
Installing the Chart
To install the chart with the release name my-release
:
helm install my-release grafana/grafana
...truncated...
---
## 5. 一次性获取所有信息
使用 `helm show all` 可以一次性获取 Chart 的所有信息,包括定义、CRD、values 和 README。
```bash
$ helm show all [chart]
示例:
$ helm show all oci://registry-1.docker.io/bitnamicharts/apache
...truncated...
annotations:
category: Infrastructure
images: |
- name: apache-exporter
image: docker.io/bitnami/apache-exporter:1.0.3-debian-11-r2
...truncated...
---
...truncated...
image:
registry: docker.io
repository: bitnami/apache
tag: 2.4.58-debian-11-r3
digest: ""
...truncated...
---
<!--- app-name: Apache -->
# Bitnami package for Apache
Apache HTTP Server is an open-source HTTP server. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
...truncated...
⚠️ 注意:输出内容通常较长,建议结合 less
或管道输出到文件查看:
$ helm show all my-chart > chart-info.yaml
6. 总结
通过本文我们了解了:
✅ helm show chart
:查看 Chart 定义
✅ helm show crds
:查看自定义资源定义
✅ helm show values
:查看默认配置
✅ helm show readme
:查看文档说明
✅ helm show all
:一次性获取所有信息
这些命令可以帮助我们快速了解 Helm Chart 的结构、配置和使用方式,是调试、部署和集成 Helm Chart 的必备工具。