我想在云运行上运行一个长时间运行的作业。此任务可能执行 30 分钟以上,并且主要发送 API 请求。cloud run 在大约 20 分钟后停止执行,从指标来看,它似乎没有识别出我的任务仍处于运行状态。所以它可能认为它正在空转和关闭容器。我想我可以在作业运行时调用服务器以保持容器处于活动状态,但是有没有办法从容器到云运行发出信号,该作业仍然处于活动状态而不是关闭容器?
我可以说它正在关闭容器,因为日志刚刚停止。然后,我对云运行端点的下一次调用,我可以再次从 NodeJS express 看到“监听”日志。
我的最终目标是在容器内安装一个存储桶,以便使用 google run 进行部署。
为了挂载存储桶,我使用了需要特权容器的 gcsfuse。(https://github.com/maciekrb/gcs-fuse-sample 等...)
使用 VirtualMachine 我会使用:
gcloud compute instances create-with-container \
[...] \
--container-privileged
Run Code Online (Sandbox Code Playgroud)
使用谷歌运行时:
gcloud beta run deploy [...]
Run Code Online (Sandbox Code Playgroud)
但是好像没有这个选项。
任何提示将不胜感激。
当我使用自托管(私有)Docker 镜像注册表进行部署时,出现以下错误:
This service will require authentication to be invoked.
Deploying container to Cloud Run service [serverless-functions-go] in project [PROJECT_ID] region [us-central1]
X Deploying new service...
. Creating Revision...
. Routing traffic...
Deployment failed
ERROR: (gcloud.beta.run.deploy) Invalid image provided in the revision template. Expected [region.]gcr.io/repo-path[:tag or @digest], obtained dtr.artifacts.xxx.com/xxxxx/xxxx/serverless-functions-go:latest
Run Code Online (Sandbox Code Playgroud)
在从我的私有 docker 镜像注册表中提取镜像之前,我需要使用如下命令:
docker login [options]
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
google-cloud-platform google-container-registry google-cloud-run
例如,
如果我的应用程序由 GCR 自动扩展,具有针对第三方身份提供商的 OAuth 2.0 + PKCE 授权代码流,我能否保证在用户登录第三方站点并重定向回后,他们将被重定向回同一个实例?
如果不是,它们被重定向回的新实例将不知道 code_verifier,并且身份验证将失败。
我的应用程序基于 Micronaut 和 GraalVM (java 11),并对以下内容进行简单调用http://httpbin.org/get:
@Controller("/api")
class HelloWorld(
@Client("http://httpbin.org")
private val httpClient: RxHttpClient
) {
private val logger = LoggerFactory.getLogger(javaClass)
@Get("/hello")
fun hello(): String {
return "Hello World!"
}
@Get("/fb")
fun fb(): Flowable<String> {
logger.info("Trying to call FB")
logger.info("Using url http://httpbin.org/get")
try {
return httpClient.retrieve("/get")
.doOnError { logger.error("Error calling fb api flowable", it) }
.doFinally { logger.info("Finished calling FB api flowable") }
} catch (ex: Exception) {
logger.error("Error calling fb api", ex)
throw ex
} finally { …Run Code Online (Sandbox Code Playgroud) 我有一个域 dummydomain.com。我希望我的网站同时在dummydomain.com和www.dummydomain.com上运行。谷歌云运行仅支持其中之一。
如果我添加 dummydomain.com 那么它会给我 IP 添加为 DNS A 和 AAAA记录。然后,如果我将 www 添加为指向 @ 的 cname,那将不起作用。
如果我添加 www.dummydomain.com 然后谷歌给我CNAME记录添加到 DNS 然后没有设置 A 记录和证书颁发给 www.dummydomain.com
应该有规定添加 A 记录和 CNAME 和证书应该颁发给 *.dummydomain.com
mapping dns google-cloud-platform google-domains google-cloud-run
我正在尝试访问安全的云运行服务。如果我在我的机器上使用 SDK 尝试它工作正常:
curl --header "Authorization: Bearer $(gcloud auth print-identity-token)"
但是,我无法使用 Python API 使用相同的服务帐户使其工作,我尝试使用 google-auth 获取访问令牌,但这给了我 401 身份验证错误。这是我用来尝试获取令牌的代码:
import google.auth
import google.auth.transport.requests
scopes = ['https://www.googleapis.com/auth/cloud-platform']
creds, projects = google.auth.default(scopes=scopes)
auth_req = google.auth.transport.requests.Request()
creds.refresh(auth_req)
# then using creds.token
Run Code Online (Sandbox Code Playgroud)
查看文档:https : //cloud.google.com/run/docs/authenticating/service-to-service#calling_from_outside_gcp它说要遵循此处的示例代码:https : //cloud.google.com/iap/docs /authentication-howto#iap_make_request-python我似乎无法按照指南进行操作,因为它说启用 IAP 但似乎 IAP 仅适用于应用程序引擎而不适用于云运行?
有没有人对此有任何建议?
谢谢
python google-authentication google-cloud-platform google-cloud-run
我部署了一个在 docker 容器中运行的 Google Cloud Run 服务。开箱即用,我似乎在服务页面的“指标”选项卡上深入了解了一些指标,例如请求计数、请求延迟等。虽然听起来请求计数可以回答我的问题,但我真正想要的是深入了解采用情况,以便我可以回答“过去一周对我的应用程序进行了多少次访问”或类似的问题。有没有办法立即获得这样的洞察力?
目前,请求计数指标报告响应/秒,所以我可以看到看起来像“0.05/s”的光点,这可以给我一些洞察力,但很难汇总。
我也尝试过使用 Monitoring > Metrics explorer,但是我没有看到我选择的指标的任何数据。如果这似乎是建议的解决方案,我正在考虑从我的应用程序中连接到 Google Analytics。谢谢!
google-cloud-platform google-cloud-monitoring google-cloud-run
我正在使用 Cloud Run + Cloud Firestore 构建一个简单的基于 Flask 的应用程序。有一种方法带来了很多数据,日志都显示这个错误:
`Memory limit of 244M exceeded with 248M used. Consider increasing the memory limit, see https://cloud.google.com/run/docs/configuring/memory-limits`
Run Code Online (Sandbox Code Playgroud)
如何增加 cloudbuild.yaml 中的内存限制?我们的 YAML 文件包含以下内容:
# cloudbuild.yaml
steps:
# build & push the container image
- name: "gcr.io/kaniko-project/executor:latest"
args: ["--cache=true", "--cache-ttl=48h", "--destination=gcr.io/$PROJECT_ID/todo:latest"]
# Deploy container image to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
args: ['beta', 'run', 'deploy', 'todo', '--image', 'gcr.io/$PROJECT_ID/todo:latest', '--region', 'us-central1', '--allow-unauthenticated', '--platform', 'managed']
Run Code Online (Sandbox Code Playgroud)
谢谢
python containers flask google-cloud-platform google-cloud-run
我正在尝试设置服务以提供身份验证服务,以便外部应用程序可以向 Cloud Run 应用程序(在 Cloud Endpoints API 网关后面)发出请求。
我遵循了服务文档之间的 Cloud Endpoints身份验证,但是在尝试访问 Cloud Run 服务时我继续收到以下错误:
401:未配置 Jwt 颁发者
在 openapi 规范中,我设置了端点安全性和 securityDefinition:
/endpoint_1:
get:
...
security:
- service_account: []
securityDefinitions:
service_account:
authorizationUrl: ""
flow: "implicit"
type: "oauth2"
x-google-issuer: "<service_account_email>"
x-google-jwks_uri: "https://www.googleapis.com/robot/v1/metadata/x509/<service_account_email>"
x-google-audiences: "https://<cloud-run-service>-pjcfvhz2qq-uc.a.run.app"
Run Code Online (Sandbox Code Playgroud)
然后使用 ESPv2 Beta 将其部署到 Cloud Run,如Cloud Endpoints 文档所述。
部署完所有内容后,我尝试从本地计算机运行以下脚本以生成已签名的 jwt 并向 Cloud Run 服务发出请求:
import os
import json
import time
import requests
import google.auth.crypt
import google.auth.jwt
now = int(time.time())
expiry_length …Run Code Online (Sandbox Code Playgroud) google-cloud-run ×10
python ×3
containers ×1
dns ×1
flask ×1
graalvm ×1
jwt ×1
kotlin ×1
mapping ×1
micronaut ×1