image.png
從結構中我們看到有不同級別的文件夾,以及一些yaml文件。
charts: 用于存放其他依賴和關聯的chart。例如應用依賴數據庫的chart。
Chart.yaml:存儲一些元數據,例如chart的信息,描述等等
templates文件夾:是所有資源的位置,我們可以看到很多kubernetes的資源文件都在這里存放。
其中的_helpers.tpl,用于存儲模板片段,可以在文件中直接使用template函數調用。
value.yaml:存儲該chart的默認值,實際安裝時可以對默認值進行覆蓋。
NOTES.txt:相當于你運行helm install的時候給用戶輸出的提示。
本著萬事百度的精神,按照百度文檔進行了安裝,安裝過程沒有問題,但是在實際使用helm進行應用install的時候發現最大的問題有4個,新手應該都能踩到
環境信息:
OS:catalina 10.15.7
Kubernetes:1.18.5(AllInOne)
安裝過程:
1、brew install helm
安裝后版本info:version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"dirty", GoVersion:"go1.14.3"}
2、按照百度方法更新國內chats源
helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
3、demo install
helm install mysql stable/mysql
報錯集合:
1、Error: failed to download "stable/nginx" (hint: running helm repo update may help)
2、Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "Deployment" in version "extensions/v1beta1"
3、Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Deployment.spec): missing required field "selector" in io.k8s.api.apps.v1.DeploymentSpec
4、helm init --service-account tiller --skip-refresh。Error: unknown command "init" for "helm"
報錯解決方案:
1、確保遠端charts倉庫有對應包
2、第2、3個問題更換stable repo源,ali的非最新版本,所以百度出來有的是手動改,有的是用shell改,根本原因還是chart源沒有實時更新以匹配k8s版本
我這里使用的是azure的:helm repo add stable http://mirror.azure.cn/kubernetes/charts/
3、init命令為helm2的命令,helm3已經棄用,可使用helm env查看環境配置信息
正確姿勢
1、brew install helm
2、helm repo add stable http://mirror.azure.cn/kubernetes/charts/
3、helm repo update
4、helm install stable/xxx