我正在 GCP 上创建一个新的 Cloud Run 服务,作为将在欧洲和亚洲拥有用户的应用程序的一部分,我想添加相应的欧洲和亚洲端点,但我只看到 us-central-1创建服务时在位置下拉列表中。
\n\n我可以发誓,最近在该下拉列表中有欧洲和亚洲的选项 \xe2\x80\x93 我错了,还是它们被删除了?
\n我正在考虑使用 Google Cloud Run 来执行一些我需要执行的类似 cron 的操作。它们将由 HTTP 调用触发。调用将返回(可能返回 202)并通过 golang goroutine 在后台继续运行。
但是,我担心 Google Cloud Run 容器在不处理 HTTP 请求时会被破坏。我可能会在处理过程中途被收获。
有没有办法告诉 GCR 让容器保持活动状态直到我完成?
当 Cloud Run 启动实例来处理 Java 服务的 HTTP 请求时,该服务必须通过网络调用联系多个外部服务才能获得有关数据的最终结论。
我不想按顺序进行这些外部服务调用,而是希望并行化它们,以便在等待 networkIO 完成时节省执行时间。这是因为我的服务本身计算量不是很大,但大部分时间都花在等待网络响应上,每个响应可能需要数百(毫秒)。简单的new Thread就可以为我完成工作。
我很好奇 Cloud Run 是否限制/禁止创建新线程,因为我在文档中找不到该信息。
(例如,Java AppEngine 要求您使用特定的 gcloudThreadManager API来管理线程。)
google_cloud_run_service.skills-online: Creating... \nError: Error creating Service: googleapi: got HTTP response code 404 with body: \n<title>Error 404 (Not Found)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style>\n 404. That\xe2\x80\x99s an error.\n\n The requested URL /apis/serving.knative.dev/v1/namespaces/skills-online/services was not found on this server. That\xe2\x80\x99s all we know.\n\n on main.tf line 11, in resource "google_cloud_run_service" "skills-online":\n 11: …Run Code Online (Sandbox Code Playgroud) google-cloud-platform gcloud terraform-provider-gcp google-cloud-run
我正在运行多个 gcloud 服务,这些服务已按以下格式自动分配网址:
https://SERVICE_NAME-XXXXXXX-ew.a.run.app/
使用这些 URL 并将这些 URL 传递给客户端并不是特别容易。另一种方法是使用自定义域,但这需要在 DNS 记录中硬编码子域(据我所知),我想避免这种情况并使用默认 URL。
使用这些 URL 的最佳实践是什么?我可以想象保留一些服务->URL 的映射并将其传递给客户端,但我想避免重新发明轮子。
service-discovery google-cloud-platform google-cloud-functions google-cloud-run
我使用 Google 的 Cloud Run(完全托管)来运行我正在构建的应用程序。当我部署新的修订版时,我希望能够在开始发送流量之前验证各种运行状况检查是否正常,但我无法找到单个(无流量)修订版的 URL。有与我正在寻找的类似的东西吗?
testing revision traffic google-cloud-platform google-cloud-run
我无法在 Docker 容器中使用 Python Firebase Admin SDK,特别是在 Google Kubernetes Engine (GKE) 上。同样的容器在Cloud Run上没有问题。我相信问题出在权限上,但我已经陷入困境。任何帮助,将不胜感激!
这是 Flask 应用程序的概要。所有三个路线都可以在 Cloud Run 上运行,前两个路线可以在 GKE 上运行,第三个路线则失败。
# realtime database address
dbAddress = 'https://[projectID].firebaseio.com/'
# initialize the firebase SDK
credentials = None # the service account should provide the credentials
firebase_admin.initialize_app(credentials,{'databaseURL': dbAddress})
@app.route('/')
def hello_world(): # works on cloud run and GKE
print('Hello, World print statement!')
return 'Hello, World!'
@app.route('/simplepost', methods = ['POST'])
def simple_post():# works on cloud run and GKE
content = request.get_json()
return {'results': …Run Code Online (Sandbox Code Playgroud) firebase google-compute-engine kubernetes google-kubernetes-engine google-cloud-run
我目前正在使用Google Cloud Run部署 API,尽管一切正常,但我现在很难理解我收到的错误。
\n我使用FastAPI在 python3 上创建了 API ,位置模型基于Pydantic\'s BaseModel。
\n为了说明这一点,我定义了一条测试路线,如下所示:
\nclass Location(BaseModel):\n lat: float\n lng: float\n\n\n@router.get(\'/test_404\')\nasync def test_404(origin: Location = Body(...),\n destination: Location = Body(...)):\n print(origin)\n print(destination)\n return {\'res\': \'ok\'}\nRun Code Online (Sandbox Code Playgroud)\n该路由应在请求正文中采用两个参数:起点和目的地,并且只有当我在本地部署它时才会这样做。\n这:
\nurl_local = "http://0.0.0.0:8080/test_404"\ndata = {\n \'origin\': {\'lat\': 104, \'lng\': 342},\n \'destination\': {\'lat\': 104, \'lng\': 342}\n}\nresp = requests.get(url_local, json = data)\nprint(resp.text)\nRun Code Online (Sandbox Code Playgroud)\n输出:
\n\'{"res":"ok"}\'\nRun Code Online (Sandbox Code Playgroud)\n当我在 Cloud Run 上部署相同的服务时,就会出现问题。我的所有其他路线都工作正常,但以下是当我将上面的代码与容器 url 一起使用时得到的输出:
\n <!DOCTYPE html>\\n\n <html lang=en>\n <meta charset=utf-8>\n …Run Code Online (Sandbox Code Playgroud) python-3.x google-cloud-platform pydantic google-cloud-run fastapi
引用https://cloud.google.com/load-balancing/docs/https/setting-up-https-serverless#enabling
虽然可以使用 Cloud Run(全托管)、Cloud Functions 和 App Engine 后端为后端服务配置 Google Cloud Armor,但此功能存在某些限制,尤其是 Cloud Run(全托管)和 App Engine。有权访问由 Google Cloud 分配给这些服务的默认网址的用户可以绕过负载均衡器并直接转到服务网址,从而绕过任何已配置的 Google Cloud Armor 安全政策。
避免针对 Cloud Run URL ( *.run.app)的攻击者绕过 Cloud Armor 的最佳方法是什么?
通常我会让 Cloud Run 只能由服务帐户调用,但 Cloud Load Balancer 不能使用服务帐户调用 Cloud Run。另一种方法是将 Cloud Load Balancer 配置为在标头中使用令牌,并将在 Cloud Run 中运行的应用程序配置为仅接受具有正确标头/令牌的调用,但我不想在应用程序中这样做。
google-cloud-platform google-cloud-armor google-cloud-load-balancer google-cloud-run
我目前正在部署一个前端,该前端将根据谷歌云平台上的使用情况动态扩展。一位朋友建议我使用谷歌云运行。我使用简单的快速服务器将我的 Angular 前端构建到 docker 映像,并部署在 google cloud run 上。这(据我所知)意味着当一个 docker 实例达到请求阈值时,另一个将启动并接受额外的请求。这与负载均衡器有何不同?我需要在谷歌云运行扩展之上的负载平衡器吗?
对于我缺乏 DevOps 知识,我提前道歉。
load-balancing google-cloud-platform google-cloud-run gcp-load-balancer
google-cloud-run ×10
fastapi ×1
firebase ×1
gcloud ×1
kubernetes ×1
pydantic ×1
python-3.x ×1
revision ×1
testing ×1
traffic ×1