簡介 本文講述的是調教 Helm 3 和 harbor 1.6+ 的經驗,從 helm2 更新到 helm 3 並且將 charts 推送到 harbor 中進行存儲,移除了原先的 helm serve,在講述怎麼操作之前先來看一下Helm 3 和 Harbor 1.6+ 的新特性。 Helm 3 ...
簡介
本文講述的是調教 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
調教開始
在瞭解了以上新的特性之後,讓我著手來操作吧
環境
- kubernetes 1.10+
- helm 3
- harbor 1.6+
調教步驟
- 確保kubernetes環境可用
- 下載並初始化 helm 3
- 安裝 harbor 1.6+
- 添加 harbor 中的 chartrepo 到 helm 3 中
- 安裝使用 helm-push 插件
1.確保kubernetes環境可用
這裡就不多說 kubernetes 環境的具體搭建過程了,搭建步驟隨處可見。
2.下載並初始化 helm 3
首先執行一下命令,下載並解壓安裝包
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 你會發現裡面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 的執行許可權和kubectl config 的許可權是一致的,通過kubectl config的方式來控制helm 3 的執行許可權。
按時安裝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
創建一個 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 成功了 ,恭喜!!!
參考
- 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
- 日拱一卒,不期速成