我正在构建NodeJs服务器,并试图利用FCM推送通知。在本地,一切都按预期工作,但在K8S集群中,我收到以下错误
FirebaseAppError: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Missing error payload".
errorInfo: {
code: 'app/invalid-credential',
message: 'Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Missing error payload".'
},
codePrefix: 'app'
我尝试在没有参数admin.initializeApp()的情况下初始化应用程序,在配置对象中保持env var与路径json键,路径有效,文件存在,env被打印出来。我试过这样的const firebase = admin.initializeApp({ credential: admin.credential.applicationDefault(), });
,显然是一样的。我试图明确地通过凭证道具与json证书,如const firebase = initializeApp({ credential: admin.credential.cert(cert) });
证书存在。我甚至尝试将firebase-admin从10降级到9。节点12请帮助
我发现一个问题。是我的K8S集群的DNS设置。所以它没有正确的访问外部世界(检查/etc/resolv.conf在pod内)必须在我的部署声明中添加dns设置,如
containers:
...
dnsPolicy: "None"
dnsConfig:
nameservers:
- 10.96.0.10 // for inner services lookup
- 8.8.8.8
searches:
- default.svc.cluster.local
- svc.cluster.local
- cluster.local