istio 给 pod 注入 sidecar 后,无法通过 pod_ip:grpc_port 直接调用 grpc - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
meso5533
V2EX    Kubernetes

istio 给 pod 注入 sidecar 后,无法通过 pod_ip:grpc_port 直接调用 grpc

  •  
  •   meso5533 2023-02-09 19:20:57 +08:00 2207 次点击
    这是一个创建于 1041 天前的主题,其中的信息可能已经有所发展或是发生改变。
    给 pod 注入 sidecar 后,无法通过 pod_ip:grpc_port 直接调用 grpc:

    rpc error: code = Unavailable desc = error reading from server: EOF

    只能通过 service_name:grpc_port 调用

    http 协议的服务倒是没这个问题

    这是怎么回事?
    14 条回复    2023-02-10 23:19:38 +08:00
    coderxy
        1
    coderxy  
       2023-02-09 19:37:35 +08:00
    可能是协议识别问题,sidecar 需要根据 service name 的 grpc-这种开头去识别协议,你直接用 ip:port 这种方式,它可能无法识别吧
    coderxy
        2
    coderxy  
       2023-02-09 19:41:58 +08:00
    @coderxy 说错了,不是 service name 的 grpc-开头,是端口映射的 grpc-
    GopherDaily
        3
    GopherDaily  
       2023-02-09 20:41:21 +08:00
    istioctl proxy-config listener xxxx ;你 pod 和 svc 不是同一个 port ?
    meso5533
        4
    meso5533  
    OP
       2023-02-09 21:15:25 +08:00
    @GopherDaily pod 和 svc 是相同的 port
    istioctl proxy-config -n test-k8s listeners test-k8s-server-9cbcf8b9b-4s2q5 --port 16071
    ADDRESS PORT MATCH DESTINATION
    0.0.0.0 16071 Trans: raw_buffer; App: http/1.1,h2c Route: 16071
    0.0.0.0 16071 ALL PassthroughCluster
    awalkingman
        5
    awalkingman  
       2023-02-09 21:41:20 +08:00
    要通过 podip 请求服务,那你得在另一个 pod 里去请求目标 podip ,所以你是在 pod A 里通过 podip 发起 grpc 请求到 pod B 吗
    meso5533
        6
    meso5533  
    OP
       2023-02-09 22:03:56 +08:00
    @newskillsget 是的
    lvroot
        7
    luvroot  
       2023-02-09 23:17:08 +08:00
    pod 之间 ip 互通需要 k8s 平台插件配置的支持。
    luvroot
        8
    luvroot  
       2023-02-09 23:19:03 +08:00
    iptables 或则 tcpdump 抓包看一下哪里配置有问题大概率网络插件配置有问题
    GopherDaily
        9
    GopherDaily  
       2023-02-10 00:29:39 +08:00
    @meso5533 https://istio.io/latest/docs/ops/diagnostic-tools/proxy-cmd/ 自己先走一遍吧,看 envoy 的 listener 包不包括 pod ip ,估计是不包括的;你走用了 mesh 了,为什么要走 pod ip ,走 svc ip 也会做负载均衡的
    GopherDaily
        10
    GopherDaily  
       2023-02-10 00:30:18 +08:00
    或者用 headless
    awalkingman
        12
    awalkingman  
       2023-02-10 19:03:49 +08:00
    @saltbo 受楼上启发,楼主把 pod 和 svc 的 yaml 文件发出来看看
    meso5533
        13
    meso5533  
    OP
       2023-02-10 23:17:59 +08:00
    apiVersion: v1
    kind: Service
    metadata:
    name: test-k8s-server-grpc
    namespace: test-k8s
    spec:
    ports:
    - name: grpc
    port: 16071
    protocol: TCP
    targetPort: 16071
    selector:
    app: test-k8s-server

    ---

    apiVersion: v1
    kind: Service
    metadata:
    name: test-k8s-server-debug
    namespace: test-k8s
    annotations:
    prometheus.io/scrape: 'true'
    prometheus.io/port: '15225'
    spec:
    ports:
    - name: debug
    port: 15225
    protocol: TCP
    targetPort: 15225
    selector:
    app: test-k8s-server

    ---

    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: test-k8s-server
    namespace: test-k8s
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: test-k8s-server
    template:
    metadata:
    name: test-k8s-server
    labels:
    app: test-k8s-server
    spec:
    containers:
    - name: test-k8s-server
    image: xxxxxx:latest
    command:
    - /root/test_k8s
    - server
    - --log-level
    - debug
    ports:
    - name: grpc
    containerPort: 16071
    - name: debug
    containerPort: 15225
    imagePullSecrets:
    - name: regcred

    grpc 的 port 无法正常通信,debug( http 协议)的 port 可以
    meso5533
        14
    meso5533  
    OP
       2023-02-10 23:19:38 +08:00
    @meso5533 通过 service_name:grpc_port 的话可以正常通信,但是通过 pod_ip:grpc_port 不行
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1378 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 16:55 PVG 00:55 LAX 08:55 JFK 11:55
    Do have faith in what you're doing.
    ubao msn 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