美文网首页
failed to parse netconf: unexpec

failed to parse netconf: unexpec

作者: wwq2020 | 来源:发表于2023-09-22 11:12 被阅读0次

    背景

    网络插件使用flannel的k8s集群,pod一只运行不起来,event出现failed to parse netconf: unexpected end of JSON input

    解决

    登录异常pod所在节点

    查看子网配置

    cat /run/flannel/subnet.env
    

    得到类似如下的配置

    FLANNEL_NETWORK=10.64.0.0/13
    FLANNEL_SUBNET=10.64.11.65/26
    FLANNEL_MTU=1450
    FLANNEL_IPMASQ=true
    

    根据pod uid查看容器id({poduid}替换为实际异常pod的uid)

    docker inspect $(docker ps -f "label=io.kubernetes.pod.uid={poduid}" -f 'label=io.kubernetes.docker.type=podsandbox' -q)

    添加pod网络配置({subnet}替换为第一步中获取的FLANNEL_SUBNET对应的值,{dst}替换为第一步中获取的FLANNEL_NETWORK对应的值,{containerid}替换为第二步中获取的容器id)

    echo '{
            "cniVersion": "0.3.1",
            "hairpinMode": true,
            "ipMasq": false,
            "ipam": {
                    "ranges": [
                            [{
                                    "subnet": "{subnet}"
                            }]
                    ],
                    "routes": [{
                            "dst": "{dst}"
                    }],
                    "type": "host-local"
            },
            "isDefaultGateway": true,
            "isGateway": true,
            "mtu": 1450,
            "name": "cbr0",
            "type": "bridge"
    }' > /var/lib/cni/flannel/{containerid}
    

    相关文章

      网友评论

          本文标题:failed to parse netconf: unexpec

          本文链接:https://www.haomeiwen.com/subject/vqdtbdtx.html