共計 2397 個字符,預計需要花費 6 分鐘才能閱讀完成。
這篇文章給大家分享的是有關使用 docker 創建 calico 網絡失敗怎么辦的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。
使用 docker 創建 calico 網絡失敗。
# docker network create --driver calico --ipam-driver calico-ipam testcalico
Error response from daemon: failed to update store for object type *libnetwork.endpointCnt: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.
查看 docker 日志:
# journalctl -fu docker
-- Logs begin at Sun 2018-05-06 10:42:10 CST. --
May 06 10:51:11 gpu16 dockerd[1045]: time= 2018-05-06T10:51:11.997488908+08:00 level=warning msg= Registering as \ 192.168.56.16:2375\ in discovery failed: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.
May 06 10:51:13 gpu16 dockerd[1045]: time= 2018-05-06T10:51:13.209441579+08:00 level=error msg= discovery error: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.
May 06 10:51:13 gpu16 dockerd[1045]: time= 2018-05-06T10:51:13.211323271+08:00 level=error msg= discovery error: client: response is invalid json. The endpoint is probably not valid etcd cluster endpoint.
May 06 10:51:13 gpu16 dockerd[1045]: time= 2018-05-06T10:51:13.213320054+08:00 level=error msg= discovery error: Unexpected watch error
首先想到的錯誤原因可能是:calico 網絡后臺的分布式存儲是 etcd,而環境中使用的 V3 版本的 etcd,而該版本在 API 方面既支持 V2 又支持 V3。docker 中未正確配置需要的版本,即 docker 要求使用的 etcd API 版本和 etcd 提供的 API 版本不一致,導致出現該問題。
驗證:命令行手動去獲取 etcd 的版本號:curl http:// etcd_ip :2379/version
# curl http://192.168.56.96:2379/version
{etcdserver : 3.1.9 , etcdcluster : 3.1.0}
返回正常。
看到 http,忽然想到我們的環境訪問 http 和 https 是需要設置代理 http_proxy 和 https_proxy,同樣,也需要設置 no_proxy 來過濾不使用代理的 IP。如果要訪問的 IP 不在 no_proxy 的范圍內,代理就會返回非法的 http 應答,而這個應答不是 json 格式的,很可能就對應了錯誤日志中的“response is invalid json”部分。在環境變量中,已經設置了 http_proxy,https_proxy 和 no_proxy,但是,docker 不能使用操作系統的這三個環境變量,我們需要配置 docker 的這三個環境變量。而且,在創建 calico 網絡時,docker 會通過 http 請求向 etcd 注冊,因此在 no_proxy 中需要包含 etcd 集群的 IP。
# mkdir -p /etc/systemd/system/docker.service.d/
# vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment= HTTP_PROXY=http://192.168.11.200:8080/ HTTPS_PROXY=https://192.168.11.200:8080/ NO_PROXY=192.168.56.109,192.168.56.96
# systemctl daemon-reload
# systemctl restart docker
待 docker 服務重啟完畢,再嘗試創建 calico 網絡,成功。
# docker network create --driver calico --ipam-driver calico-ipam testcalico
53cbe9b82451b017be6d5d80a8fc17e320f6269521dfeabb7e07fd79ee92e3ef
感謝各位的閱讀!關于“使用 docker 創建 calico 網絡失敗怎么辦”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!