kubernetes-19:helm安装

  • 2019 年 11 月 21 日
  • 筆記

目录

(1).本文目的与helm使用场景

(2).helm安装

(3).helm常用命令

(1).本文目的与helm使用场景

有些时候我还是需要用helm辅助我做一些事情,更加具备性价比。

比如readness,liveness的命令行/脚本的写法,特别是一些中间件,我只需要用helm执行后查看yaml,然后拷贝出对应的yaml部分即可。自己写太麻烦了,写一次还不一定能对。

另外,helm/charts毕竟是官方提供,我可以参考他的yaml中的一些高级和优雅的做法。

生产环境我是不使用helm容器化的,扩容等操作很麻烦,维护和管理也是个问题。最关键的是会隐藏容器化的细节,我一般都喜欢在一个官方/权威的yaml模板上修改,顺带能再次了解其机制。

(2).helm安装

下载二进制包

https://github.com/helm/helm/releases

我选择最新版本:

wget https://storage.googleapis.com/kubernetes-helm/helm-v2.12.3-linux-amd64.tar.gz

tar -xzvf helm-v2.12.3-linux-amd64.tar.gz

mv linux-amd64 helm-2.12.3

mv helm-2.12.3 /app/3rd

ln -s /app/3rd/helm-2.12.3/helm /bin/helm

helm是客户端,tiller是服务端。

[root@future 3rd]# helm version

Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}

Error: could not find tiller

这次报错是因为找不到服务端 Tiller,接下来我们部署服务端。

nohup /app/3rd/helm-2.12.3/tiller > /data/logs/helm-2.12.3/nohup.out &

helm version

Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}

Error: the server could not find the requested resource (get pods)

需要:

直接执行时,默认会监听 44134 和 44135 端口,44134 端口用于和 helm 进行通信,而 44135 主要是用于做探活的,在部署至 K8S 时使用。

当我们使用客户端连接时,只需设置 HELM_HOST 环境变量即可。

export HELM_HOST=localhost:44134

将上述环境变量放入/etc/profile,再执行source /etc/profile使其生效。

如下:

[root@future ~]# export HELM_HOST=localhost:44134

[root@future ~]#

[root@future ~]# helm version

Client: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}

Server: &version.Version{SemVer:"v2.12.3", GitCommit:"eecf22f77df5f65c823aacd2dbd30ae6c65f186e", GitTreeState:"clean"}

完成初始化操作:

helm init

helm repo update

(3).helm常用命令

helm初始化命令:

helm init

仓库更新命令:

helm repo update

强制删除已经容器化的组件:

helm delete –purge kafka-manager

新增仓库命令:

helm repo add local http://localhost:8879

这个命令可能会常用到,因为默认仓库有可能有网络问题,会添加新的仓库。

查看仓库列表

helm repo list