這篇文章將為大家詳細講解有關如何在國內優雅地使用Rancher,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
Rancher進入中國已經4年,并在今年2月份完成了中國本土化和國產化。作為一款開源的企業級Kubernetes管理平臺,我們一直十分關注Rancher社區用戶的各種訴求。在我們的技術社區中,我們常常收到這樣的抱怨:從Github上下載資源慢、拉鏡像十分耗時、無法使用library和system-library等。這些大大降低了國內用戶的Rancher使用體驗。
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資源
拉取鏡像慢,等待集群啟動時間長
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情況
無法使用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的錯誤日志
為了改善大家的使用體驗,我們針對以上問題分別提出了解決方法。
為了讓大家更流暢地使用Rancher,我們將一些資源mirror到了國內,提供給國內用戶使用。接下來,我們將詳細介紹如何使用這些資源。
我們已經將Rancher的常用組件放在國內服務器上,訪問此鏈接 ,即可下載所需的組件,從此告別failed: Operation timed out
我們已經在阿里云鏡像倉庫中同步了一份原版的鏡像,倉庫地址: registry.cn-hangzhou.aliyuncs.com
注意:阿里云鏡像倉庫中的rancher鏡像不支持使用 latest、stable等tags,必須指定版本號,例如v2.4.2
接下來,我們來demo如何操作:
1、 使用阿里云鏡像倉庫的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的鏡像名稱
2、 設置默認鏡像倉庫
從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之后即可正常使用
關于如何在國內優雅地使用Rancher就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。