新装的 k8s 网络 pod 无法 ping 通 svc - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
defunct9
0.01D
V2EX    Kubernetes

新装的 k8s 网络 pod 无法 ping 通 svc

  •  
  •   defunct9 2021-05-28 13:29:05 +08:00 5297 次点击
    这是一个创建于 1597 天前的主题,其中的信息可能已经有所发展或是发生改变。
    奇怪的问题,如果部署一个 nginx 的 svc,然后用 kubectl run curl --image=radial/busyboxplus:curl -i --tty --rm,启动一个临时 pod,在里面 ping nginx-svc 不通,但是 ping nginx-svc.default 是通的。如果换个 pod,kubectl run curl --image=busybox -i --tty --rm,在里面 ping nginx-svc 就通了。

    如果换到阿里的 k8s 的 ack,起这个 busyboxplus:curl,在里面 nginx-svc 是通的,这是什么古怪问题,有人遇到过吗?
    32 条回复    2021-11-12 13:01:38 +08:00
    comphilip
        1
    comphilip  
       2021-05-28 13:33:43 +08:00
    这个问题一般是底层的 CNI 插件配置错了。
    swulling
        2
    swulling  
       2021-05-28 13:41:53 +08:00 via iPhone
    不要用 Ping 来测试 Service,没有意义。

    ping 的通 ping 不通和 Service 可用不可用没啥关系。
    CaptainDK
        3
    CaptainDK  
       2021-05-28 13:47:53 +08:00
    几个 node ? ping 的通和 ping 不通的 pod 分别运行在哪个 node 上?
    GjriFeu
        4
    GjriFeu  
       2021-05-28 13:54:12+08:00 via iPhone
    检查一下 node 上的 cni pod 起来了没
    zoharSoul
        5
    zoharSoul  
       2021-05-28 14:01:38 +08:00   11
    开 ssh,我上去看看
    qinxi
        6
    qinxi  
       2021-05-28 14:09:17 +08:00
    @zoharSoul #5 哈哈哈哈 经典
    zoharSoul
        7
    zoharSoul  
       2021-05-28 14:21:23 +08:00   2
    @qinxi #6 这个楼主整天这么回帖, 我终于有搞回去的机会了 /狗头
    defunct9
        8
    defunct9  
    OP
       2021-05-28 14:28:55 +08:00
    @GjriFeu flannel 正常。注意是换个不同版本的 busybox pod 就可以通
    defunct9
        9
    defunct9  
    OP
       2021-05-28 14:29:48 +08:00
    @CaptainDK 1 个 master,2 个 worker 。无论那个 worker 只要跑这个 radial/busyboxplus:curl 就不行。
    defunct9
        10
    defunct9  
    OP
       2021-05-28 14:31:39 +08:00
    @swulling ping 是个基本测试手段. 用 curl http://nginx-svc 一样不通。curl http://nginx-svc.default 就是通的
    defunct9
        11
    defunct9  
    OP
       2021-05-28 14:33:30 +08:00
    @swulling can't resolve 才去 ping 的

    [ root@curl:/ ]$ curl http://my-nginx
    curl: (6) Couldn't resolve host'my-nginx'


    [ root@curl:/ ]$ curl http://my-nginx.default
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
    body {
    width: 35em;
    margin: 0 auto;
    font-family: Tahoma, Verdana, Arial, sans-serif;
    }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>

    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>

    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    daimaosix
        12
    daimaosix  
       2021-05-28 15:44:29 +08:00
    开 ssh,让我上去看看
    masha
        13
    masha  
       2021-05-28 16:11:11 +08:00
    开 ssh,让我上去看看
    masha
        14
    masha  
       2021-05-28 16:12:22 +08:00
    看下有问题 pod 的 /etc/resolv.conf?
    masha
        15
    masha  
       2021-05-28 16:13:28 +08:00
    swulling
        16
    swulling  
       2021-05-28 16:22:10 +08:00   1
    @defunct9 你这个 debug 顺序好奇怪,都 can't resolve 了,为啥还要 ping
    defunct9
        17
    defunct9  
    OP
       2021-05-28 16:25:01 +08:00
    @swulling nslookup 和 ping 都试试啊。nslookup 和 ping 都不行。
    defunct9
        18
    defunct9  
    OP
       2021-05-28 16:27:56 +08:00
    @masha 跟阿里 ack 正常的 resolv.conf 比过,一样。dns-debugging-resolution 的也试了一遍了,不行。coredns 降到 1.6.7,加上 upstream,同时打开 pods verified 和 autopath @kubernetes,也不行。
    defunct9
        19
    defunct9  
    OP
       2021-05-28 16:30:06 +08:00
    @swulling 这个 debug 顺序没什么奇怪的吧,pod 都是大平板市场,普通开放的 svc 都是 cluster ip,ping 一下,然后再看服务是否正常,是正常顺序吧。
    raysonx
        20
    raysonx  
       2021-05-28 16:38:37 +08:00
    kube-proxy 默认的 backend
    raysonx
        21
    raysonx  
       2021-05-28 16:42:01 +08:00
    kube-proxy 默认的 backend 是 iptables,通过 DNAT 做的转发。因为只转发了 service 的端口,你是 ping 不通的。
    如果用 ipvs backend,service 的 ip 会自动赋给所有 node 的 ipvs 虚拟网卡,是可以 ping 通的。
    如果是有些 node 通有些不通,可能是 cni 有问题,或者是那个节点的 kube-proxy 没启动。
    raysonx
        22
    raysonx  
       2021-05-28 16:45:12 +08:00
    楼主提供的信息太少了,单纯这样也只是猜测。不如开 SSH 让我上去看看 ( doge )
    iphoneXr
        23
    iphoneXr  
       2021-05-28 16:55:01 +08:00
    开 ssh,让我上去看看
    KaynW
        24
    KaynW  
       2021-05-28 17:00:25 +08:00
    没头绪, 开 ssh, 让我上去看看
    masha
        25
    masha  
       2021-05-28 17:06:04 +08:00
    @defunct9
    不是,我的意思是你看看这个 https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/#known-issues,dns search 记录的问题。从你的现象来看就是从 search 记录找不到*.default 这个后缀。 我印象里以前也遇到过这个问题,不过不搞 k8s 比较久了没清晰记忆了。
    defunct9
        26
    defunct9  
    OP
       2021-05-28 17:34:04 +08:00
    不用猜了,busybox 的 bug,升级过的 busybox 就是好的。所以么,不要随便用 radial/busyboxplus:curl 这个镜像。另外,这个镜像在阿里的 ack 居然是好的,猜不透原因。
    julyclyde
        27
    julyclyde  
       2021-05-28 17:57:09 +08:00
    clusterIP 本来就不是让你 ping 的
    shyy228
        28
    shyy228  
       2021-05-28 18:10:33 +08:00 via iPhone
    开 ssh,我上去看看
    mritd
        29
    mritd  
       2021-05-28 18:59:18 +08:00 via iPhone
    coredns 默认域有问题
    skies457
        30
    skies457  
       2021-05-28 23:07:37 +08:00
    可能是 ndots 的问题,试试在 /etc/resolv.conf 里加上 options ndots:5

    https://pracucci.com/kubernetes-dns-resolution-ndots-options-and-why-it-may-affect-application-performances.html
    simo
        31
    simo  
       2021-05-29 10:44:54 +08:00
    开 ssh,我上去看看看不懂
    mogging
        32
    mogging  
       2021-11-12 13:01:38 +08:00 via Android
    上 nodelocaldns 试试
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5577 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 37ms UTC 07:46 PVG 15:46 LAX 00:46 JFK 03:46
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86