K
K
Kumu's wiki
搜索文档…
Helm 命令

Helm Completion

helm 命令补全,类似 kubectl completion
1
source <(helm completion bash)
Copied!
建议把以上命令根据实际的 shell 加入到对应的配置文件中永久生效,如 bash 为 ~/.bashrc,zsh 则为 ~/.zshrc

Helm Create

根据给定的名字创建一个新的 chart
1
# helm create test
2
Creating test
3
# tree -aF test
4
test
5
├── charts/ // 可选,用于存放当前 Chart 依赖的其它 Chart 的说明文件
6
├── Chart.yaml // 用于描述 Chart 的元数据信息
7
├── .helmignore // Helm charts 打包时要忽略的信息,类似 .gitignore 和 .dockerignore
8
├── templates/ // 可选,模板文件目录
9
│ ├── deployment.yaml
10
│ ├── _helpers.tpl
11
│ ├── ingress.yaml
12
│ ├── NOTES.txt
13
│ ├── serviceaccount.yaml
14
│ ├── service.yaml
15
│ └── tests/ // 测试文件
16
│ └── test-connection.yaml
17
└── values.yaml // 模板默认值
18
19
3 directories, 10 files
Copied!

Helm Dependency

管理 chart 依赖
例如,这个 Chart.yaml 声明了两个依赖:
1
# Chart.yaml
2
dependencies:
3
- name: nginx
4
version: "1.2.3"
5
repository: "https://example.com/charts"
6
- name: memcached
7
version: "3.2.1"
8
repository: "https://another.example.com/charts"
Copied!
也可以通过 file:// 方式指定本地地址
1
# Chart.yaml
2
dependencies:
3
- name: nginx
4
version: "1.2.3"
5
repository: "file://../dependency_chart/nginx"
Copied!

Helm Dependency build

基于 Chart.lock 文件重新构建 charts/ 目录,选择一个 chart 目录执行命令:
1
# helm dependency build
2
Hang tight while we grab the latest from your chart repositories...
3
...Successfully got an update from the "incubator" chart repository
4
...Successfully got an update from the "stable" chart repository
5
...Successfully got an update from the "bitnami" chart repository
6
Update Complete. ⎈Happy Helming!⎈
7
Saving 1 charts
8
Downloading nginx from repo https://charts.bitnami.com/bitnami
9
Deleting outdated charts
Copied!
如果没有 Chart.lock 文件,该命令会同 helm dependency update 一样创建此文件
1
# cat Chart.lock
2
dependencies:
3
- name: nginx
4
repository: https://charts.bitnami.com/bitnami
5
version: 5.1.7
6
digest: sha256:3c3b4389ddb5d3ff6ef489d49713a369ec9d8474d04a8591f4be9ee78a122bc9
7
generated: "2020-03-05T15:30:02.76679778+08:00"
Copied!
如果 Chart.yaml 变更了,Chart.lock 文件没有更新,则 helm dependency build 命令会执行失败,需要先执行 update 操作
1
# helm dependency build
2
Error: the lock file (Chart.lock) is out of sync with the dependencies file (Chart.yaml). Please update the dependencies
Copied!

Helm Dependency list

列出给定 chart 的依赖信息:
1
# helm dependency list
2
NAME VERSION REPOSITORY STATUS
3
nginx 5.1.7 https://charts.bitnami.com/bitnami ok
4
# rm -f charts/nginx-5.1.7.tgz
5
# helm dependency list
6
NAME VERSION REPOSITORY STATUS
7
nginx 5.1.7 https://charts.bitnami.com/bitnami missing
Copied!

Helm Dependency update

基于 Chart.yaml 内容更新 charts/
1
# helm dependency update
2
Hang tight while we grab the latest from your chart repositories...
3
...Successfully got an update from the "incubator" chart repository
4
...Successfully got an update from the "stable" chart repository
5
...Successfully got an update from the "bitnami" chart repository
6
Update Complete. ⎈Happy Helming!⎈
7
Saving 2 charts
8
Downloading nginx from repo https://charts.bitnami.com/bitnami
9
Downloading mysql from repo https://charts.bitnami.com/bitnami
10
Deleting outdated charts
11
# cat Chart.lock // update 命令会同步更新 Chart.lock
12
dependencies:
13
- name: nginx
14
repository: https://charts.bitnami.com/bitnami
15
version: 5.1.7
16
- name: mysql
17
repository: https://charts.bitnami.com/bitnami
18
version: 6.9.2
19
digest: sha256:8a9ccbc57ff8e49cd5d788b736a0daeba182afe714721d1e5d17f13384935a6a
20
generated: "2020-03-05T15:44:24.017928459+08:00"
Copied!

Helm Env

打印出 Helm 所有在使用的环境变量
1
# helm env
2
HELM_BIN="helm"
3
HELM_DEBUG="false"
4
HELM_KUBECONTEXT=""
5
HELM_NAMESPACE="default"
6
HELM_PLUGINS="/root/.local/share/helm/plugins"
7
HELM_REGISTRY_CONFIG="/root/.config/helm/registry.json"
8
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
9
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"
Copied!

Helm Get

获取 release 扩展信息
1
# helm get -h
2
3
This command consists of multiple subcommands which can be used to
4
get extended information about the release, including:
5
6
- The values used to generate the release
7
- The generated manifest file
8
- The notes provided by the chart of the release
9
- The hooks associated with the release
10
11
Usage:
12
helm get [command]
13
14
Available Commands:
15
all download all information for a named release // 所有的信息
16
hooks download all hooks for a named release // hooks 相关
17
manifest download the manifest for a named release // 主要是 K8s 资源信息,Deployment、ConfigMap 等等
18
notes download the notes for a named release // 注解
19
values download the values file for a named release // 变量内容
Copied!
1
# helm get hooks helm-grafana
2
---
3
# Source: grafana/templates/tests/test.yaml
4
apiVersion: v1
5
kind: Pod
6
metadata:
7
name: helm-grafana-test
8
labels:
9
helm.sh/chart: grafana-5.0.4
10
app.kubernetes.io/name: grafana
11
app.kubernetes.io/instance: helm-grafana
12
app.kubernetes.io/version: "6.6.2"
13
app.kubernetes.io/managed-by: Helm
14
annotations:
15
"helm.sh/hook": test-success
16
namespace: default
17
spec:
18
serviceAccountName: helm-grafana-test
19
containers:
20
- name: helm-grafana-test
21
image: "bats/bats:v1.1.0"
22
command: ["/opt/bats/bin/bats", "-t", "/tests/run.sh"]
23
volumeMounts:
24
- mountPath: /tests
25
name: tests
26
readOnly: true
27
volumes:
28
- name: tests
29
configMap:
30
name: helm-grafana-test
31
restartPolicy: Never
Copied!

Helm History

获取 release 历史
1
# helm history helm-grafana
2
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
3
1 Tue Mar 3 15:12:14 2020 deployed grafana-5.0.4 6.6.2 Install complete
Copied!

Helm Install

安装一个 chart,官方示例如下:
1
$ helm install -f myvalues.yaml myredis ./redis
2
$ helm install --set name=prod myredis ./redis
3
$ helm install --set-string long_int=1234567890 myredis ./redis
4
$ helm install -f myvalues.yaml -f override.yaml myredis ./redis
5
$ helm install --set foo=bar --set foo=newbar myredis ./redis
Copied!

Helm Lint

Helm chart lint 命令,验证 chart 格式是否正确。
1
# helm lint
2
==> Linting .
3
[INFO] Chart.yaml: icon is recommended
4
5
1 chart(s) linted, 0 chart(s) failed
Copied!

Helm List

releases 列表
默认只列出已经部署或者失败的 release,--uninstalled--all 选项可以列出更多,还可以采用 --uninstalled --failed 组合模式。通过 --filter 还可以支持搜索正则。
1
$ helm list --filter 'ara[a-z]+'
2
NAME UPDATED CHART
3
maudlin-arachnid Mon May 9 16:07:08 2016 alpine-0.1.0
Copied!
1
# helm list -h
2
...
3
Usage:
4
helm list [flags]
5
6
Aliases:
7
list, ls
8
9
Flags:
10
-a, --all show all releases without any filter applied
11
-A, --all-namespaces list releases across all namespaces
12
-d, --date sort by release date
13
--deployed show deployed releases. If no other is specified, this will be automatically enabled
14
--failed show failed releases
15
-f, --filter string a regular expression (Perl compatible). Any releases that match the expression will be included in the results
16
-h, --help help for list
17
-m, --max int maximum number of releases to fetch (default 256) // 设置 0 并不会显示所有的,会使用服务器的默认值,该值可能高于 256
18
--offset int next release name in the list, used to offset from start value
19
-o, --output format prints the output in the specified format. Allowed values: table, json, yaml (default table)
20
--pending show pending releases
21
-r, --reverse reverse the sort order
22
-q, --short output short (quiet) listing format
23
--superseded show superseded releases
24
--uninstalled show uninstalled releases (if 'helm uninstall --keep-history' was used)
25
--uninstalling show releases that are currently being uninstalled
26
...
Copied!

Helm Package

把一个 chart 目录归档
1
# helm package test/
2
Successfully packaged chart and saved it to: /root/shuihan/test-0.1.0.tgz
Copied!
1
# helm package -h
2
...
3
Usage:
4
helm package [CHART_PATH] [...] [flags]
5
6
Flags:
7
--app-version string set the appVersion on the chart to this version
8
-u, --dependency-update update dependencies from "Chart.yaml" to dir "charts/" before packaging
9
-d, --destination string location to write the chart. (default ".")
10
-h, --help help for package
11
--key string name of the key to use when signing. Used if --sign is true
12
--keyring string location of a public keyring (default "/root/.gnupg/pubring.gpg")
13
--sign use a PGP private key to sign this package
14
--version string set the version on the chart to this semver version
15
...
Copied!

Helm Plugin

安装、列表或者卸载 Helm plugins
1
# helm plugin -h
2
3
Manage client-side Helm plugins.
4
5
Usage:
6
helm plugin [command]
7
8
Available Commands:
9
install install one or more Helm plugins
10
list list installed Helm plugins
11
uninstall uninstall one or more Helm plugins
12
update update one or more Helm plugins
13
14
Flags:
15
-h, --help help for plugin
16
...
Copied!

Helm Pull

从仓库下载一个 chart 并(可选)解包在本地目录下。
1
# helm pull bitnami/nginx
Copied!
1
# helm pull -h
2
...
3
Usage:
4
helm pull [chart URL | repo/chartname] [...] [flags]
5
6
Aliases:
7
pull, fetch
8
9
Flags:
10
--ca-file string verify certificates of HTTPS-enabled servers using this CA bundle
11
--cert-file string identify HTTPS client using this SSL certificate file
12
-d, --destination string location to write the chart. If this and tardir are specified, tardir is appended to this (default ".")
13
--devel use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.
14
-h, --help help for pull
15
--key-file string identify HTTPS client using this SSL key file
16
--keyring string location of public keys used for verification (default "/root/.gnupg/pubring.gpg")
17
--password string chart repository password where to locate the requested chart
18
--prov fetch the provenance file, but don't perform verification
19
--repo string chart repository url where to locate the requested chart
20
--untar if set to true, will untar the chart after downloading it
21
--untardir string if untar is specified, this flag specifies the name of the directory into which the chart is expanded (default ".")
22
--username string chart repository username where to locate the requested chart
23
--verify verify the package before installing it
24
--version string specify the exact chart version to install. If this is not specified, the latest version is installed
25
...
Copied!

Helm Repo

添加、列表、移除、更新以及索引 chart 仓库
1
# helm repo -h
2
3
This command consists of multiple subcommands to interact with chart repositories.
4
5
It can be used to add, remove, list, and index chart repositories.
6
7
Usage:
8
helm repo [command]
9
10
Available Commands:
11
add add a chart repository
12
index generate an index file given a directory containing packaged charts
13
list list chart repositories
14
remove remove a chart repository
15
update update information of available charts locally from chart repositories
16
...
Copied!
1
# helm repo list
2
NAME URL
3
incubator http://storage.googleapis.com/kubernetes-charts-incubator
4
bitnami https://charts.bitnami.com/bitnami
5
# helm repo remove bitnami
6
"bitnami" has been removed from your repositories
7
# helm repo add bitnami https://charts.bitnami.com/bitnami
8
"bitnami" has been added to your repositories
9
# helm repo update
10
Hang tight while we grab the latest from your chart repositories...
11
...Successfully got an update from the "stable" chart repository
12
...Successfully got an update from the "incubator" chart repository
13
...Successfully got an update from the "bitnami" chart repository
14
Update Complete. ⎈ Happy Helming!⎈
Copied!
helm repo index 用于给 chart 仓库目录生成 index.yaml 文件索引。
1
# helm repo index -h
2
3
Read the current directory and generate an index file based on the charts found.
4
5
This tool is used for creating an 'index.yaml' file for a chart repository. To
6
set an absolute URL to the charts, use '--url' flag.
7
8
To merge the generated index with an existing index file, use the '--merge'
9
flag. In this case, the charts found in the current directory will be merged
10
into the existing index, with local charts taking priority over existing charts.
11
12
Usage:
13
helm repo index [DIR] [flags]
14
15
Flags:
16
-h, --help help for index
17
--merge string merge the generated index into the given index
18
--url string url of chart repository
Copied!

Helm Rollback

release 版本回滚
1
# helm rollback -h
2
3
This command rolls back a release to a previous revision.
4
5
The first argument of the rollback command is the name of a release, and the
6
second is a revision (version) number. If this argument is omitted, it will
7
roll back to the previous release.
8
9
To see revision numbers, run 'helm history RELEASE'.
10
11
Usage:
12
helm rollback <RELEASE> [REVISION] [flags]
13
14
Flags:
15
--cleanup-on-fail allow deletion of new resources created in this rollback when rollback fails
16
--dry-run simulate a rollback
17
--force force resource update through delete/recreate if needed
18
-h, --help help for rollback
19
--no-hooks prevent hooks from running during rollback
20
--recreate-pods performs pods restart for the resource if applicable
21
--timeout duration time to wait for any individual Kubernetes operation (like Jobs for hooks) (default 5m0s)
22
--wait if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout
Copied!

Helm Search

charts 搜索
1
# helm search
2
3
Search provides the ability to search for Helm charts in the various places
4
they can be stored including the Helm Hub and repositories you have added. Use
5
search subcommands to search different locations for charts.
6
7
Usage:
8
helm search [command]
9
10
Available Commands:
11
hub search for charts in the Helm Hub or an instance of Monocular // https://hub.helm.sh/
12
repo search repositories for a keyword in charts
Copied!

Helm Show

展示 chart 信息
1
# helm show
2
3
This command consists of multiple subcommands to display information about a chart
4
5
Usage:
6
helm show [command]
7
8
Aliases:
9
show, inspect
10
11
Available Commands:
12
all shows all information of the chart
13
chart shows the chart's definition
14
readme shows the chart's README
15
values shows the chart's values
Copied!

Helm Status

显示 release 状态信息
1
# helm status helm-grafana
2
NAME: helm-grafana
3
LAST DEPLOYED: Tue Mar 3 15:12:14 2020
4
NAMESPACE: default
5
STATUS: deployed
6
REVISION: 1
7
NOTES:
8
1. Get your 'admin' user password by running:
9
10
kubectl get secret --namespace default helm-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
11
12
2. The Grafana server can be accessed via port 80 on the following DNS name from within your cluster:
13
14
helm-grafana.default.svc.cluster.local
15
16
Get the Grafana URL to visit by running these commands in the same shell:
17
18
export POD_NAME=$(kubectl get pods --namespace default -l "app=grafana,release=helm-grafana" -o jsonpath="{.items[0].metadata.name}")
19
kubectl --namespace default port-forward $POD_NAME 3000
20
21
3. Login with the password from step 1 and the username: admin
22
#################################################################################
23
###### WARNING: Persistence is disabled!!! You will lose your data when #####
24
###### the Grafana pod is terminated. #####
25
#################################################################################
Copied!

Helm Template

本地渲染模板
通过 helm 自定义选项并输出。
1
# helm template test bitnami/grafana --set-string image.tag=5.0.4 // 修改镜像 tag
Copied!

Helm Test

针对已部署的 release 运行测试,这些测试在已安装 chart 中定义好了。

Helm Uninstall

卸载一个 release
1
# helm uninstall helm-grafana
2
release "helm-grafana" uninstalled
Copied!

Helm Upgrade

release 升级
1
$ helm upgrade -f myvalues.yaml -f override.yaml redis ./redis
2
$ helm upgrade --set foo=bar --set foo=newbar redis ./redis
Copied!

Helm Verify

验证指定的 chart 已签名并且有效

Helm Version

查看 helm 版本信息
1
# helm version
2
version.BuildInfo{Version:"v3.1.1", GitCommit:"afe70585407b420d0097d07b21c47dc511525ac8", GitTreeState:"clean", GoVersion:"go1.13.8"}
Copied!
最近更新 1yr ago