【发布时间】:2022-10-13 00:10:03
【问题描述】:
我无法在 Okteto 的 pod 上访问我的 gRPC 端口。
pod 充当 gRPC 服务器。
我收到
状态码:14 不可用
对于 Postman gRPC 调用,以及
状态码=不可用,描述=io异常, 原因=io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) 失败:连接被拒绝
来自另一个 pod 的呼叫。
gRPC 连接之前已经过测试并与 Minikube 一起使用,现在我正在尝试迁移到 Okteto。
pod 已部署并运行,没有任何其他问题,它也使用正确的 Docker 映像。配置基于documentation。
我的配置文件如下,kubernetes.yaml:
apiVersion: apps/v1 kind: Deployment metadata: name: datahandler labels: app: datahandler spec: replicas: 1 selector: matchLabels: app: datahandler template: metadata: labels: app: datahandler spec: containers: - name: datahandler image: xxxxx/datahandler ports: - containerPort: 8080 - containerPort: 8980 imagePullPolicy: IfNotPresent --- apiVersion: v1 kind: Service metadata: name: datahandler-service spec: type: ClusterIP ports: - port: 8080 name: resttestport protocol: TCP targetPort: 8080 - port: 8980 name: grpcport protocol: TCP targetPort: 8980 selector: app: datahandler --- kind: Ingress apiVersion: networking.k8s.io/v1 metadata: name: ingress annotations: dev.okteto.com/generate-host: "true" kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/backend-protocol: "GRPC" nginx.ingress.kubernetes.io/ssl-redirect: "true" spec: rules: - host: this-name-does-not-matter http: paths: - path: / pathType: Prefix backend: service: name: datahandler-service port: name: grpcport和 Dockerfile:
FROM openjdk:8 ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} datahandler-0.0.1-SNAPSHOT.jar EXPOSE 8080 EXPOSE 8980 ENTRYPOINT ["java","-jar","/datahandler-0.0.1-SNAPSHOT.jar"]更新 1
gRPC 服务器 pod 的日志如下,同时我修改了端口。
Pod 看起来很健康。
根据它假设在指定端口上侦听的日志(如果上面附加的配置正确):2022-10-11 14:34:14.64 UTCGRPC Server started, listening on 50051This 是 gRPC 服务器 pod 的代码,this 是调用方 pod 的代码,您可以在其中看到我尝试以多种不同方式访问 gRPC 服务器 pod,但均未成功。
2022-10-11 14:33:56.65 UTC 2022-10-11 14:33:56.65 UTC . ____ _ __ _ _ 2022-10-11 14:33:56.65 UTC /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ 2022-10-11 14:33:56.65 UTC( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 2022-10-11 14:33:56.65 UTC \\/ ___)| |_)| | | | | || (_| | ) ) ) ) 2022-10-11 14:33:56.65 UTC ' |____| .__|_| |_|_| |_\__, | / / / / 2022-10-11 14:33:56.65 UTC =========|_|==============|___/=/_/_/_/ 2022-10-11 14:33:56.67 UTC :: Spring Boot :: (v2.6.6) 2022-10-11 14:33:56.67 UTC 2022-10-11 14:33:57.13 UTC2022-10-11 14:33:57.124 INFO 1 --- [ main] e.m.datahandler.DatahandlerApplication : Starting DatahandlerApplication v0.0.1-SNAPSHOT using Java 1.8.0_342 on ec33nw-datahandler-6ff77457cd-5ztm9 with PID 1 (/datahandler-0.0.1-SNAPSHOT.jar started by root in /) 2022-10-11 14:33:57.13 UTC2022-10-11 14:33:57.130 INFO 1 --- [ main] e.m.datahandler.DatahandlerApplication : No active profile set, falling back to 1 default profile: "default" 2022-10-11 14:34:03.87 UTC2022-10-11 14:34:03.874 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-10-11 14:34:03.94 UTC2022-10-11 14:34:03.949 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-10-11 14:34:03.95 UTC2022-10-11 14:34:03.949 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.60] 2022-10-11 14:34:04.28 UTC2022-10-11 14:34:04.284 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-10-11 14:34:04.28 UTC2022-10-11 14:34:04.284 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6918 ms 2022-10-11 14:34:12.85 UTC2022-10-11 14:34:12.851 INFO 1 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator' 2022-10-11 14:34:13.16 UTC2022-10-11 14:34:13.159 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2022-10-11 14:34:13.24 UTC2022-10-11 14:34:13.249 INFO 1 --- [ main] e.m.datahandler.DatahandlerApplication : Started DatahandlerApplication in 19.001 seconds (JVM running for 20.935) 2022-10-11 14:34:14.64 UTCGRPC Server started, listening on 50051
【问题讨论】:
-
豆荚健康吗?它是否在 0.0.0.0: 8980 上监听?没有任何日志或源代码,很难知道发生了什么。您是否可以在 github 存储库上对您的问题进行最少的复制,以便我们看一下?
-
@RamiroBerrelleza 请查看更新后的帖子。 Pod 似乎很健康,并且假设在配置正确的情况下侦听指定端口。我还附上了 Pod 代码的链接。
标签: java docker kubernetes grpc okteto