只有在Kubernetes内部运行时,Firebase Admin Go SDK才会获得x509证书错误

问题描述 投票:2回答:1

我目前正在使用Firebase Admin Go SDK处理一个项目来处理身份验证并使用实时数据库。当我在本地运行它时(通过运行go run main.go)项目正常工作。当我通过Docker镜像(或GKE,我已经测试过两者)在Minikube中运行它时,每当我尝试进行任何Firestore调用时,我都会收到此错误:

transport: authentication handshake failed: x509: certificate signed by unknown authority

这是我在服务器上用来调用DB的代码:

// Initialize the app 
opt := option.WithCredentialsFile("./serviceAccountKey.json")
app, err := firebase.NewApp(context.Background(), nil, opt)
// This is the first call I attempt to make, and where the error is thrown
// Create the client
client, err := app.Firestore(context.Background())
iter := client.Collection("remoteModels").Documents(context.Background())
snaps, err := iter.GetAll()
if err != nil {
    logger.Log.Warn("Error getting all remoteModels")
    fmt.Println(err)
    return err
}  

这是我的Dockerfile,它添加了Firebase从控制台提供的服务帐户密钥:

FROM scratch

ADD main /
ADD serviceAccountKey.json /

EXPOSE 9090

ENTRYPOINT ["/main", "-grpc-port=9090", "-http-port=9089", "-env=prod"]

我在关于在Kubernetes中运行的文档中找不到任何内容。 能从Kubernetes连接到Firestore需要做些什么吗?

firebase go kubernetes google-cloud-firestore firebase-admin
1个回答
5
投票

如果您使用基于阿尔卑斯山的图像尝试运行apk add ca-certificates它看起来像一个错误。 安装ca证书,它应该解决问题

© www.soinside.com 2019 - 2024. All rights reserved.