You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

K3s中GRPC容器连接异常:DNS解析失败问题排查

问题排查与解决步骤

核心问题:Service与Pod标签不匹配

你的Deployment中Pod的标签为app: server-pod,但Service的selector配置成了app: vei-deployment,完全不匹配。这会导致Service无法关联到任何Pod,Endpoints资源为空,进而引发DNS解析相关的连接故障。

修复步骤:

  1. 修改vei-service.yaml的selector字段,使其与Deployment的Pod标签一致:
spec:
  selector:
    app: server-pod  # 替换原有的vei-deployment
  1. 重新应用Service配置:
kubectl apply -f vei-service.yaml
  1. 验证Service是否成功关联Pod:
kubectl get endpoints server-pod

正常输出会显示对应3个Pod的IP(与Deployment的replicas:3对应)。

其他建议修复的配置问题

1. 完善Ingress的TLS配置

当前Ingress的tls字段为空,需指定已创建的TLS Secret(用于GRPCS加密):

spec:
  tls:
    - hosts:
        - kong.gamov.dev
      secretName: kong-gamov-dev-tls  # 替换为你的TLS Secret名称

2. 对齐GRPC连接方式与服务配置

如果你的GRPC服务器启用了TLS,客户端需使用secure_channel而非insecure_channel,并配置证书:

import grpc
from grpc import ssl_channel_credentials

credentials = ssl_channel_credentials()
channel = grpc.secure_channel('server-pod:50051', credentials)

验证DNS解析

修复Service后,在集群内任意Pod中测试DNS解析:

nslookup server-pod

正常情况下会返回该Service的ClusterIP。

内容的提问来源于stack exchange,提问作者Johnney

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 10:50:37