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