zoukankan      html  css  js  c++  java
  • 创建calico网络报错client response is invalid json

    使用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常用操作
    docker-vlanhost
    打补丁说明
    mycat RULEs
    头晕的android SDK Manager and 找不到真机
    高格-一些特点的话题【抛入抛出关联】
    流程配置中心中的委托设置无法查看全部流程的问题
    验证flash player 是否正常
    kdpkg安装包解压
    go新环境Mac安装,包含okexchain
  • 原文地址:https://www.cnblogs.com/styshoo/p/8998339.html
Copyright © 2011-2022 走看看