簡介
本文講述的是調教 Helm 3 和 harbor 1.6+ 的經驗,從 helm2 更新到 helm 3 并且將 charts 推送到 harbor 中進行存儲踱阿,移除了原先的 helm serve,在講述怎么操作之前先來看一下Helm 3 和 Harbor 1.6+ 的新特性寂汇。
Helm 3 新特性
- 移除了 Tiller
- 不同的 namespace 可以使用相同的 Release Name
- 簡化模板對象
.Capabilities
- 使用
JSONSchema
驗證 charts 的 Values - 將
requirements.yaml
合并到Chart.yaml
中 - helm install 時需要指定 Release Name,開啟自動生成需要
--generate-name
參數 - 支持 push 到遠端 registry (如:harbor)
- 移除 helm serve
- 命令行變化(將原先的命令保留為別名Aliases)
-
helm delete
-->helm uninstall
-
helm inspect
->helm show
-
helm fetch
->helm pull
-
- go 導入路徑改變
k8s.io/helm
-->helm.sh/helm
具體新特性可以參考Helm 3 新特性,或者參考Helm 官方文檔
Harbor v1.6.0 新特性
- 支持存儲 helm charts
- ...
這里沒什么好說的十艾,想要了解更多關于Harbor的漾稀,可以參考官方Github
調教開始
在了解了以上新的特性之后模闲,讓我著手來操作吧
環(huán)境
- kubernetes 1.10+
- helm 3
- harbor 1.6+
調教步驟
- 確保kubernetes環(huán)境可用
- 下載并初始化 helm 3
- 安裝 harbor 1.6+
- 添加 harbor 中的 chartrepo 到 helm 3 中
- 安裝使用 helm-push 插件
1.確保kubernetes環(huán)境可用
這里就不多說 kubernetes 環(huán)境的具體搭建過程了,搭建步驟隨處可見崭捍。
2.下載并初始化 helm 3
首先執(zhí)行一下命令尸折,下載并解壓安裝包
wget https://get.helm.sh/helm-v2.14.2-linux-amd64.tar.gz
tar zxvf helm-v2.14.2-linux-amd64.tar.gz
cd linux-amd64
cp helm /usr/local/bin
解壓之后,你如果使用過helm 2 你會發(fā)現里面tiller的二進制文件不見了缕贡,前文的新特性中已經說了翁授,helm 3 已經移除了 tiller
接下來初始化 helm
helm init
默認添加官方 repo stable https://kubernetes-charts.storage.googleapis.com
3.安裝 harbor 1.6+
這里我使用的是 harbor 官方提供的 charts repo
,好奇心驅使我打開了這個網站 https://helm.goharbor.io/
這熟悉的界面讓我嚴重懷疑是使用的 helm serve 啟的 repo(滑稽臉)
添加harbor repo
helm repo add goharbor https://helm.goharbor.io
這個 repo 只有一個charts harbor ,對應的 harbor 版本為1.8.1
在安裝之前我們需要配置一下 kube config context
查看當前的context
kubectl config current-context
設置 context 指定對應的 namespace 晾咪,不指定使用的是 default
kubectl config set-context <current-context> --namespace test
這里是因為收擦,helm 3 開始helm 3 的執(zhí)行權限和kubectl config 的權限是一致的,通過kubectl config的方式來控制helm 3 的執(zhí)行權限谍倦。
按時安裝harbor ,這里為了簡化測試操作塞赂,我關閉了數據卷的掛載并使用的是 NodePort 方式進行訪問。
helm -n test install harbor goharbor/harbor --set persistence.enabled=false --set expose.type=nodePort --set expose.tls.enabled=false --set externalURL=http://192.168.10.196:30002
參數說明:
- persistence.enabled=false 關閉存儲昼蛀,為了方便操作宴猾,真實使用時需要掛在存儲
- expose.type=nodePort 使用 NodePort 訪問
- expose.tls.enabled=false 關閉tls
- externalURL=http://192.168.10.196:30002 設置登錄 harbor 的外部鏈接
出現以下返回,就證明已經開始安裝了
NAME: harbor
LAST DEPLOYED: 2019-07-23 11:00:38.525597536 +0800 CST m=+0.690703892
NAMESPACE: test
STATUS: deployed
NOTES:
Please wait for several minutes for Harbor deployment to complete.
Then you should be able to visit the Harbor portal at https://core.harbor.domain.
For more details, please visit https://github.com/goharbor/harbor.
4.添加 harbor 中的 chartrepo 到 helm 3 中
harbor 裝好之后叼旋,我們訪問 http://192.168.10.196:30002 進行登錄 harbor, harbor 的默認賬號密碼是 admin/Harbor12345
新建一個chart repo
創(chuàng)建一個 test 用戶
添加 repo 到 helm 中
helm repo add test http://192.168.10.76:30002/chartrepo/chart_repo
5.安裝使用 helm-push 插件
helm plugin install https://github.com/chartmuseum/helm-push
這里最好本地配置一下 github 的 dns 地址仇哆,不然可能會出現鏈接超時的現象
安裝好插件之后,就可以push charts 到 harbor 里面了
helm push grafana-0.0.2.tgz test --username test --password xxx
出現以上就說明 push 成功了 夫植,恭喜6锾蕖S脱丁!
參考
- https://github.com/chartmuseum/helm-push
- https://github.com/goharbor/harbor
- https://github.com/helm/helm
- Github: https://github.com/innerpeacez
- 個人Blog: https://ipzgo.top
- 日拱一卒延欠,不期速成