【Kubernetes】【helm】安装与命令

举报
huahua.Dr 发表于 2021/06/25 16:00:41 2021/06/25
【摘要】 【Kubernetes】【helm】安装与使用

一、安装部署Helm,在集群master节点上安装:

  • 从官网下载helm安装包:https://helm.sh/docs/intro/install/;linux下直接wget下载:wget https://get.helm.sh/helm-xx-linux-xx.tar.gz
  • 解压helm包:tar -zxvf helm-xx-linux-xx.tar.gz
  • 配置path环境变量,将解压目录下的helm文件移动到/usr/local/bin/heml:mv ./heml /usr/local/bin/heml。
    • 说明:为什么要移动到/usr/local/bin?应为该路径包含在path环境变量路径中,移动到该路径就相当于helm配置了环境变量,可以直接使用heml命令了。
  • 查看helm版本,看是否已经安装成功
    • # helm version
    • version.BuildInfo{Version:"v3.3.3", GitCommit:"55e3ca022e40fe200fbc855938995f40b2a68ce0", GitTreeState:"clean", GoVersion:"go1.14.9"}
  • 配置命令补全功能(可选,输入helm后可以按一下或两下Tab键进行补全或提示可选的命令)
    • 执行命令:# vim ~/.bashrc
    • 在文本中添加以下行后保存退出:source <(helm completion bash)
    • 执行命令:# source ~/.bashrc

遇到的问题:

在使用helm输入后,按一次或两次Tab键以想命令补全或提示,发现报错如下:

-bash: _get_comp_words_by_ref: command not found

问题原因:缺少bash-completion工具

解决方案:

安装bash-completion:# yum install bash-completion -y

执行bash-completion:# source /usr/share/bash-completion/bash_completion

重新加载~/.bashrc:# source ~/.bashrc

二、Helm命令大全:

命令

描述

实例

helm completion [command]

会生成helm自动补全命令的脚本,如上面的配置命令补全功能使用到;

Available Commands:

bash --generate autocompletions script for bash

zsh--generate autocompletions script for zsh

 

helm completion bash,将helm命令以bash脚本形式输出

helm dependency [command]

管理chart的依赖;

Available Commands:

  build      -- rebuild the charts/ directory based on the Chart.lock file

  list        --list the dependencies for the given chart

  update      --update charts/ based on the contents of Chart.yaml

 

 

helm create NAME [flags]

创建一个chart模板目录

Flags:

  -h, --help             help for create

  -p, --starter string   the name or absolute path to Helm starter scaffold

 

helm env [flags]

输出helm的环境配置信息,包括helm的仓库路径、配置文件路径等信息

# helm env

HELM_BIN="helm"

HELM_CACHE_HOME="/root/.cache/helm"

HELM_CONFIG_HOME="/root/.config/helm"

HELM_DATA_HOME="/root/.local/share/helm"

HELM_DEBUG="false"

HELM_KUBEAPISERVER=""

HELM_KUBECONTEXT=""

HELM_KUBETOKEN=""

HELM_NAMESPACE="default"

HELM_PLUGINS="/root/.local/share/helm/plugins"

HELM_REGISTRY_CONFIG="/root/.config/helm/registry.json"

HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"

HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"

helm get [command] RELEASE_NAME

根据chart软件包发布的release版本名,查询对应的相关信息

 including:

- The values used to generate the release

- The generated manifest file

- The notes provided by the chart of the release

- The hooks associated with the release

 

Available Commands:

  all         --download all information for a named release

  hooks      -- download all hooks for a named release

  manifest    --download the manifest for a named release

  notes      --download the notes for a named release

  values      --download the values file for a named release

 

helm history RELEASE_NAME [flags]

History prints historical revisions for a given release.

A default maximum of 256 revisions will be returned. Setting '--max'

configures the maximum length of the revision list returned.

The historical release set is printed as a formatted table.

Flags:

  -h, --help            help for history

      --max int         maximum number of revision to include in history (default 256)

  -o, --output format   prints the output in the specified format. Allowed values: table, json, yaml (default table)

 

helm install [NAME] [CHART] [flags]

This command installs a chart archive.

The install argument must be a chart reference, a path to a packaged chart,

a path to an unpacked chart directory or a URL.

There are five different ways you can express the chart you want to install:

 

1. By chart reference: helm install mymaria example/mariadb

2. By path to a packaged chart: helm install mynginx ./nginx-1.2.3.tgz

3. By path to an unpacked chart directory: helm install mynginx ./nginx

4. By absolute URL: helm install mynginx https://example.com/charts/nginx-1.2.3.tgz

5. By chart reference and repo url: helm install --repo https://example.com/charts/ mynginx nginx

helm lint PATH [flags]

This command takes a path to a chart and runs a series of tests to verify that

the chart is well-formed.

 

helm list [flags]

This command lists all of the releases for a specified namespace (uses current namespace context if namespace not specified).

 

helm package [CHART_PATH] [...] [flags]

This command packages a chart into a versioned chart archive file. If a path

is given, this will look at that path for a chart (which must contain a

Chart.yaml file) and then package that directory.

 

helm plugin [command]

Manage client-side Helm plugins.

Available Commands:

  install     install one or more Helm plugins

  list        list installed Helm plugins

  uninstall   uninstall one or more Helm plugins

  update      update one or more Helm plugins

 

 

helm pull [chart URL | repo/chartname] [...] [flags]

Retrieve a package from a package repository, and download it locally.

 

 

helm repo [command]

This command consists of multiple subcommands to interact with chart repositories.

It can be used to add, remove, list, and index chart repositories.

Available Commands:

  add         add a chart repository

  index       generate an index file given a directory containing packaged charts

  list        list chart repositories

  remove      remove one or more chart repositories

  update      update information of available charts locally from chart repositories

 

 

helm rollback <RELEASE> [REVISION] [flags]

The first argument of the rollback command is the name of a release, and the

second is a revision (version) number. If this argument is omitted, it will

roll back to the previous release.

 

helm search [command]

Search provides the ability to search for Helm charts in the various places

they can be stored including the Helm Hub and repositories you have added. Use

search subcommands to search different locations for charts.

Available Commands:

  hub         search for charts in the Helm Hub or an instance of Monocular

  repo        search repositories for a keyword in charts

 

 

helm show [command]

This command consists of multiple subcommands to display information about a chart

Available Commands:

  all         show all information of the chart

  chart       show the chart's definition

  readme      show the chart's README

  values      show the chart's values

 

 

helm status RELEASE_NAME [flags]

This command shows the status of a named release.

 

helm template [NAME] [CHART] [flags]

Render chart templates locally and display the output.

 

helm test [RELEASE] [flags]

The test command runs the tests for a release.

The argument this command takes is the name of a deployed release.

The tests to be run are defined in the chart that was installed.

Flags:

  -h, --help               help for test

      --logs               dump the logs from test pods (this runs after all tests are complete, but before any cleanup)

      --timeout duration   time to wait for any individual Kubernetes operation (like Jobs for hooks) (default 5m0s)

 

 

 

helm uninstall RELEASE_NAME [...] [flags]

This command takes a release name and uninstalls the release.

 

helm upgrade [RELEASE] [CHART] [flags]

This command upgrades a release to a new version of a chart.

 

helm verify PATH [flags]

Verify that the given chart has a valid provenance file

 

 helm version [flags]

Show the version for Helm.

 

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。