本文來源Rancher Labsnode
Rancher進入中國已經4年,並在今年2月份完成了中國本土化和國產化。做爲一款開源的企業級Kubernetes管理平臺,咱們一直十分關注Rancher社區用戶的各類訴求。在咱們的技術社區中,咱們經常收到這樣的抱怨:從Github上下載資源慢、拉鏡像十分耗時、沒法使用library和system-library等。這些大大下降了國內用戶的Rancher使用體驗。linux
ksd@Hailong-MacBook-Pro /tmp wget https://github.com/rancher/rke/releases/download/v1.0.8/rke_linux-amd64 --2020-05-07 10:20:30-- https://github.com/rancher/rke/releases/download/v1.0.8/rke_linux-amd64 Resolving github.com... 13.250.177.223 Connecting to github.com|13.250.177.223|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/108337180/26415380-8ebd-11ea-834a-af693358e976?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200507%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200507T022031Z&X-Amz-Expires=300&X-Amz-Signature=f4659696f17f619d1d42bfc0a78d998c12c34506475983eb523f150a22a4ce51&X-Amz-SignedHeaders=host&actor_id=0&repo_id=108337180&response-content-disposition=attachment%3B%20filename%3Drke_linux-amd64&response-content-type=application%2Foctet-stream [following] --2020-05-07 10:20:31-- https://github-production-release-asset-2e65be.s3.amazonaws.com/108337180/26415380-8ebd-11ea-834a-af693358e976?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200507%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200507T022031Z&X-Amz-Expires=300&X-Amz-Signature=f4659696f17f619d1d42bfc0a78d998c12c34506475983eb523f150a22a4ce51&X-Amz-SignedHeaders=host&actor_id=0&repo_id=108337180&response-content-disposition=attachment%3B%20filename%3Drke_linux-amd64&response-content-type=application%2Foctet-stream Resolving github-production-release-asset-2e65be.s3.amazonaws.com... 52.216.65.240 Connecting to github-production-release-asset-2e65be.s3.amazonaws.com|52.216.65.240|:443... failed: Operation timed out. Retrying.
沒法從Github上下載Rancher資源git
拉取鏡像慢,等待集羣啓動時間長github
2020/05/07 03:06:27 [INFO] Pulling image [rancher/rke-tools:v0.1.56] on host [172.17.206.119], try #1 2020/05/07 03:09:16 [INFO] Pulling image [rancher/hyperkube:v1.17.5-rancher1] on host [172.17.206.119], try #1 2020/05/07 03:09:16 [INFO] cluster [c-zfz4g] provisioning: Pre-pulling kubernetes images
拉取rancher鏡像經常出現timeout狀況docker
沒法使用library和system-library,致使沒法使用應用商店服務器
2020/05/07 03:31:31 [ERROR] CatalogController helm3-library [catalog] failed with : Remote commit check failed: Repo [https://git.rancher.io/helm3-charts] is not accessible: Get https://git.rancher.io/repos/helm3-charts/commits/master: net/http: request canceled (Client.Timeout exceeded while awaiting headers) 2020/05/07 03:31:33 [ERROR] CatalogController library [catalog] failed with : Remote commit check failed: Repo [https://git.rancher.io/charts] is not accessible: Get https://git.rancher.io/repos/charts/commits/master: net/http: request canceled (Client.Timeout exceeded while awaiting headers) 2020/05/07 03:31:34 [ERROR] CatalogController system-library [catalog] failed with : Remote commit check failed: Repo [https://git.rancher.io/system-charts] is not accessible: Get https://git.rancher.io/repos/system-charts/commits/release-v2.4: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
rancher/rancher日誌,顯示一些關於git.rancher.io timeout的錯誤日誌微信
爲了改善你們的使用體驗,咱們針對以上問題分別提出瞭解決方法。app
爲了讓你們更流暢地使用Rancher,咱們將一些資源mirror到了國內,提供給國內用戶使用。接下來,咱們將詳細介紹如何使用這些資源。less
咱們已經將Rancher的經常使用組件放在國內服務器上,訪問此連接 ,便可下載所需的組件,今後告別failed: Operation timed out
阿里雲
咱們已經在阿里雲鏡像倉庫中同步了一份原版的鏡像,倉庫地址: registry.cn-hangzhou.aliyuncs.com
注意:阿里雲鏡像倉庫中的rancher鏡像不支持使用 latest、stable等tags,必須指定版本號,例如v2.4.2
接下來,咱們來demo如何操做:
一、 使用阿里雲鏡像倉庫的Rancher鏡像啓動Rancher
docker run -itd -p 80:80 -p 443:443 \ --restart=unless-stopped \ -e CATTLE_AGENT_IMAGE="registry.cn-hangzhou.aliyuncs.com/rancher/rancher-agent:v2.4.2" \ registry.cn-hangzhou.aliyuncs.com/rancher/rancher:v2.4.2
CATTLE_AGENT_IMAGE
: 指定rancher-agent的鏡像名稱
二、 設置默認鏡像倉庫
從UI導航到Settings,而後編輯system-default-registry
,Value設置爲registry.cn-hangzhou.aliyuncs.com
system-default-registry的參數設置請參考官方文檔。
接下來,咱們按照官方文檔添加自定義集羣,只須要等待集羣啓動成功便可。下圖中列出了system-project中全部的workload,這些workload均使用了阿里雲的鏡像倉庫registry.cn-hangzhou.aliyuncs.com
內的鏡像:
僅需3-5分鐘就能完成整個集羣的搭建,將大幅節省時間,提升工做效率。
Rancher默認使用Github上的repo做爲應用商店的URL,若是出現timeout狀況,能夠將Catalog URL替換成碼雲的地址。
每一個repo的對應關係以下:
(點擊文章開頭連接可獲取可複製版本)
那麼如何修改Catalog URL呢?
導航到全局或項目級別的Apps -> Manage Catalogs
點擊列表右側的省略號 -> Edit
將Catalog URL替換成碼雲中的地址便可,點擊Save
此時,對應的Catalog的狀態變爲Refreshed,等待其變爲Active以後便可正常使用
以上提到的資源,咱們會經過定時任務天天從Github上拉取,同步到國內。也許存在延遲或同步失敗的狀況,若是發現任何問題,歡迎在官方微信技術交流羣或官方論壇中向咱們反饋。