简体   繁体   English

pubsub.NewClient方法卡在GKE golang上

[英]pubsub.NewClient method stuck on GKE golang

I am developing a golang app that uses Google Pub/Sub client library. 我正在开发使用Google Pub / Sub客户端库的golang应用程序。 I am using Google container engine for deployment. 我正在使用Google容器引擎进行部署。 I followed the following steps for deployment - 我按照以下步骤进行了部署-

  1. Build golang binary using CGO_ENABLED=0 GOOS=linux go build -o bin/app app.go 使用CGO_ENABLED=0 GOOS=linux go build -o bin/app app.go构建golang二进制文件CGO_ENABLED=0 GOOS=linux go build -o bin/app app.go
  2. Build a docker image using dockerfile shown below. 使用下面显示的dockerfile构建docker映像。
  3. Create kubernetes deployment. 创建kubernetes部署。

Dockerfile - Dockerfile-

FROM scratch 
ADD bin/app /
CMD ["/app"]

The app starts fine and I can see some initial debug logs. 该应用程序启动正常,我可以看到一些初始调试日志。 However, when I try to instantiate a pub/sub client using client, err := pubsub.NewClient(ctx, projectId) , the method call never returns. 但是,当我尝试使用client, err := pubsub.NewClient(ctx, projectId)实例化发布/ client, err := pubsub.NewClient(ctx, projectId) ,该方法调用将永远不会返回。 I do not see the log message printed right after this statement. 在此声明之后,我没有看到打印出的日志消息。

I have "Cloud Pub/Sub" permission enabled on my GKE cluster. 我在GKE群集上启用了“云发布/订阅”权限。 Also, the app runs without any issues on my local machine. 此外,该应用程序在我的本地计算机上运行也没有任何问题。

What might be the issue? 可能是什么问题?

Okay so I finally found the problem and its solution. 好的,所以我终于找到了问题及其解决方案。 My image does not contain any SSL certificates which are required for the pub/sub client (and many other libraries of course) to communicate. 我的映像不包含发布/订阅客户端(当然还有许多其他库)进行通信所需的任何SSL证书。

Adding my local machine's /etc/ssl/certs/ca-certificates.crt file to the docker image's /etc/ssl/certs/ location solved the problem. 将我本地计算机的/etc/ssl/certs/ca-certificates.crt文件添加到Docker映像的/etc/ssl/certs/位置即可解决此问题。

This awesome post at codeship is where I learned this solution. 在Codeship上的这篇很棒的帖子是我学习此解决方案的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM