HELM 是k8的包管理工具 ,像linux系統的包管理器,如yum,apt等,很方便的把yaml 文件部署到k8s上面!
第一部: 安裝篇
1.helm包下載地址:https://get.helm.sh/helm-v3.6.1-linux-amd64.tar.gz
2.解壓 && 移動到 /usr/bin 目錄下: tar -xvf helm-v3.6.0-rc.1-linux-amd64.tar.gz && cd linux-amd64/ && mv helm /usr/bin
3.執行 helm 顯示如下說明安裝成功:
第二部:配置倉庫篇
helm repo add apphub https://apphub.aliyuncs.com ## apphub #倉庫名 https://apphub.aliyuncs.com # 倉庫地址
helm repo list # 查看倉庫
helm repo update # 更新倉庫
helm repo remove baidu # 刪除倉庫
第三部: HELM 部署應用
helm search repo nginx -l # 搜索應用 nginx,並查看歷史版本
helm install xnginx nginx # 安裝應用 xnginx #安裝新的應用名稱 nginx # 原來的應用名稱
helm install nginx aliyuncs/nginx --set service.type=NodePort --set persistence.enabled=false #對外暴露端口方式為 NodePort 默認為 LoadBanlancer # 不啟用持久化存儲
helm uninstall xnginx # 卸載應用
helm list # 應用的狀態
helm status nginx # =nginx 的信息
helm get all xnginx : # 獲取 xnginx的詳細配置信息
第四部:報錯排查
如果有報錯,有些舊倉庫往會最新版 K8S,這里是 v1.18.2按照,會報錯,可以換個倉庫或者下載下來修改后本地安裝
報錯
Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "Deployment" in version "extensions/v1beta1" helm pull apphub/nginx-ingress --untar grep -irl "extensions/v1beta1" nginx-ingress | grep -ir deployment grep -irl "extensions/v1beta1" nginx-ingress | grep -ir deploy | xargs sed -i 's#extensions/v1beta1#apps/v1#g' helm install nginx1 ./nginx-ingress/
第五部分:helm 自動補全命令
source <(helm completion bash)
echo "source <(helm completion bash)" >> ~/.bashrc
source /usr/share/bash-completion/bash_completion
#先添加常用的chart源
http://mirror.azure.cn/kubernetes/charts-incubator/
http://mirror.azure.cn/kubernetes/charts/
helm repo add stable https://charts.helm.sh/stable
helm repo add incubator https://charts.helm.sh/incubator
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add aliyuncs https://apphub.aliyuncs.com