标签: google-cloud-run

无法使用内部 IP 在 Cloud Run 和计算引擎之间进行连接

我有一个在 Cloud Run 上运行的服务,以及一个在 Compute Engine 上运行的 MYSQL、MongoDB 数据库。目前,我正在使用公共 IP 在它们之间进行连接,我想使用内部 IP 来提高性能,但我找不到解决此问题的方法,请帮助我一些想法,谢谢。

google-compute-engine google-cloud-platform google-cloud-run google-vpc

7
推荐指数
1
解决办法
2651
查看次数

Google Drive API - 自动查询消息

我正在使用这个Ghost 插件在 Google Drive 上存储图像数据。最近,图像已停止加载,并下载了此错误页面来代替图像:

https://github.com/robincsamuel/ghost-google-drive

该站点在 Google Cloud Run 上的容器化 Ghost 实例中运行,来源在这里

我是否需要在某处打开支持票来解决这个问题?有问题的网站在这里

编辑:这是用于访问保存的内容的代码。

jwtClient.authorize(function(err, tokens) {
        if (err) {
          return next(err);
        }
        const drive = google.drive({
          version: API_VERSION,
          auth: jwtClient
        });
        drive.files.get(
          {
            fileId: id
          },
          function(err, response) {
            if (!err) {
              const file = response.data;
              const newReq = https
                .request(
                  file.downloadUrl + "&access_token=" + tokens.access_token,
                  function(newRes) {
                    // Modify google headers here to cache!
                    const headers = newRes.headers;
                    headers["content-disposition"] =
                      "attachment; filename=" + file.originalFilename; …
Run Code Online (Sandbox Code Playgroud)

google-drive-api docker ghost-blog google-cloud-run

7
推荐指数
1
解决办法
222
查看次数

从 GCP 安装文档运行“Hello Cloud Run with Python”时,日志中出现“[CRITICAL] WORKER TIMEOUT”

按照此处教程,我有以下 2 个文件:

应用程序

from flask import Flask, request

app = Flask(__name__)


@app.route('/', methods=['GET'])
def hello():
    """Return a friendly HTTP greeting."""
    who = request.args.get('who', 'World')
    return f'Hello {who}!\n'


if __name__ == '__main__':
    # Used when running locally only. When deploying to Cloud Run,
    # a webserver process such as Gunicorn will serve the app.
    app.run(host='localhost', port=8080, debug=True)
Run Code Online (Sandbox Code Playgroud)

文件

# Use an official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.7-slim

# Install production dependencies.
RUN pip install …
Run Code Online (Sandbox Code Playgroud)

python flask gunicorn google-cloud-platform google-cloud-run

7
推荐指数
2
解决办法
3793
查看次数

通过 YAML 部署 Cloud Run 会提供名为“yourservicename-00001-soj”且已存在不同配置的修订版

使用以下命令部署新的 Cloud Run 修订版时,

gcloud run services replace service.yaml
Run Code Online (Sandbox Code Playgroud)

部署失败并出现此错误

ERROR: (gcloud.run.services.replace) ALREADY_EXISTS: Revision named 'yourservicename-00001-soj' with different configuration already exists.
Run Code Online (Sandbox Code Playgroud)

当您按照 Google 的文档进行操作时,就会发生这种情况,该文档指示您将当前服务 YAML 描述提取到文件中,进行编辑,然后重新部署它。

google-cloud-run

6
推荐指数
1
解决办法
1751
查看次数

无法在 Cloud Run 上使用 gcsfuse 装载存储桶

借助 Google Cloud Run 第二代运行时,现在可以使用 gcsfuse 挂载 Google 存储桶。

https://cloud.google.com/run/docs/tutorials/network-filesystems-fuse

python3 示例运行良好。不幸的是,我的 Dockerfile 不断收到此错误:

bin/fusermount: failed to open /dev/fuse: Permission denied
mountWithArgs: mountWithConn: Mount: mount: running /bin/fusermount: exit status 1
Run Code Online (Sandbox Code Playgroud)

截屏

Dockerfile

# https://github.com/chiaen/docker-gcsfuse
FROM golang:1.17.5-alpine as gcsfuse
RUN apk add --no-cache git
ENV GOPATH /go
RUN go get -u github.com/googlecloudplatform/gcsfuse

FROM composer:2 as vendor
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install --ignore-platform-reqs --no-interaction --prefer-dist

FROM craftcms/nginx:7.4

ENV MNT_DIR /mnt/gcs

USER root
RUN apk add --no-cache mysql-client postgresql-client ca-certificates …
Run Code Online (Sandbox Code Playgroud)

google-cloud-storage docker gcsfuse google-cloud-run

6
推荐指数
1
解决办法
4345
查看次数

如何在 cloudbuild.yaml 中指定用于云运行的自定义 service.yaml?

我在 Google Cloud Run 服务上部署了一个 docker 容器。它有一个非常基本的cloudbuild.yaml文件,可以从 git 推送到主分支触发。

\n

我希望将云运行机的内存从512MB自动增加到8GB。我知道可以在 Cloud Run UI 中单击“EDIT @\xc2\xa0DEPLOY NEW REVISION”,然后手动选择 8gb。但我希望自动进行此设置。

\n

您可以通过以下方式从 Cloud Run 获取 .yaml:

\n
gcloud run services describe SERVICE --format export > service.yaml\n
Run Code Online (Sandbox Code Playgroud)\n
gcloud run services describe SERVICE --format export > service.yaml\n
Run Code Online (Sandbox Code Playgroud)\n

您可以将当前的 .yaml 半自动替换为:

\n

gcloud run services replace service.yaml

\n

但是,有什么方法可以让实际的 Cloud Build将部署容器映像service.yaml中的自定义加载到 Cloud Run步骤吗?

\n

cloudbuild.yaml

\n
apiVersion: serving.knative.dev/v1\nkind: Service\nmetadata:\n  annotations:\n    client.knative.dev/user-image: \'gcr.io/project/service:ebbe555\'\n    run.googleapis.com/ingress: all\n    run.googleapis.com/ingress-status: all\n …
Run Code Online (Sandbox Code Playgroud)

google-cloud-platform google-cloud-build google-cloud-run cloudbuild.yaml

6
推荐指数
1
解决办法
6437
查看次数

在 Google Cloud Run 上使用 uwsgi 重写 Django 子域

我正在将 Django 网站迁移到 GCP 并首次使用 Google Cloud Run。体验很棒。我对域映射功能也非常满意,但我在将 www 子域转发到裸域 URL 时遇到问题。为了实现一致的页面分析,我希望浏览的访问者被https://www.mycooldomainname.com301 重定向到https://mycooldomainname.com(真实域编辑)

DNS设置

我将 bare 和 www 子域添加到 Cloud Run 自定义域:

GCR

并在我的注册商处添加了所需的 A、AAA 和 CNAME 记录:

登记员

传播完所有内容后,我可以访问我的网站 和https://mycooldomainname.comhttps://www.mycooldomainname.com但如何配置转发/重写?

从我读到的其他帖子中,人们使用 Google Cloud DNS 实现了这一点,看起来他们使用了别名来进行转发。

在这种情况下,我尝试通过 uwsgi 进行转发:

网络服务器设置

django 应用程序通过 uwsgi 使用此配置提供服务 - 请注意重定向规则:

[uwsgi]
plugins-dir = /usr/lib/uwsgi/plugins
plugins = router_uwsgi
route-uri = ^(.*)\/\/www\.(.*)$ redirect-301:$1//$2
hook-master-start = unix_signal:15 gracefully_kill_them_all
http-socket = 0.0.0.0:8000
cheaper = 1
cheaper-algo = backlog
workers = …
Run Code Online (Sandbox Code Playgroud)

regex django uwsgi google-cloud-dns google-cloud-run

6
推荐指数
1
解决办法
293
查看次数

如何在使用 Terraform 的 Cloud Run 部署中激活“CPU 始终分配”

我正在尝试使用 Terraform 在 Cloud Run 中部署容器。我已经手动部署容器并正确运行。现在,我需要使用 Terraform 部署它以创建可复制的环境。我已经成功配置了几乎所有参数,除了这个。

CPU 始终被分配

在我手动部署的情况下,更改此参数非常容易。

手动部署

但我没有在 terraform 文件、main.tf 或variables.tf 中找到配置此参数的位置。我正在使用这个模块:https://github.com/GoogleCloudPlatform/terraform-google-cloud-run

有没有人做过或者可以帮助我指出是否可能以及配置的位置。

太感谢了。

google-cloud-platform terraform google-cloud-run

6
推荐指数
1
解决办法
2416
查看次数

Golang gRPC 连接客户端错误 - “错误读取服务器前言:http2:框架太大”

我正在写一个 go 客户端来消费

conn, err := grpc.DialContext(ctx, serverAddr, grpc.WithBlock(), grpc.WithReturnConnectionError(), getTransportCredential(false))
Run Code Online (Sandbox Code Playgroud)

上面的调用挂起直到上下文超时并返回以下错误

failed to dial: context deadline exceeded: connection error: desc = "error reading server preface: http2: frame too large"
Run Code Online (Sandbox Code Playgroud)

getTransportCredential(insecure bool)定义如下

func getTransportCredential(insecure bool) grpc.DialOption {
    if insecure {
        return grpc.WithTransportCredentials(insecure2.NewCredentials())
    }

    rootCAs, err := x509.SystemCertPool()
    if err != nil {
        panic(err)
    }
    if rootCAs == nil {
        fmt.Println("SystemCertPool is nil")
        rootCAs = x509.NewCertPool()
    }

    caCert := `-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----`

    if caCert != "" {
        // Append …
Run Code Online (Sandbox Code Playgroud)

go google-cloud-platform http2 grpc google-cloud-run

6
推荐指数
1
解决办法
1万
查看次数

gcloud.functions.deploy 无法创建或更新 Cloud Run 服务

每当我尝试使用gcloud-cli.

\n

这是我运行来部署我的函数的命令

\n
gcloud functions deploy [cloud_funtion_name]\n--gen2 --region=us-central1\n--runtime=nodejs18\n--entry-point=[function_entry_point]\n--trigger-http\n--allow-unauthenticated\n--max-instances=83\n
Run Code Online (Sandbox Code Playgroud)\n

在无休止地卡在Cloud run service台阶上大约 10 分钟后,我收到此错误

\n
Preparing function...done.                                                                                                                                     \nX Deploying function...                                                                                                                                        \n  \xe2\x9c\x93 [Build] Logs are available at [logs_link]                                                                                                                                                        \n  \xe2\x9c\x93 [Service]                                                                                                                                                  \n  . [ArtifactRegistry]                                                                                                                                         \n  . [Healthcheck]                                                                                                                                              \n  . [Triggercheck]                                                                                                                                             \nFailed.                                                                                                                                                        \nERROR: (gcloud.functions.deploy) OperationError: code=13, \nmessage=Could not create or update Cloud Run service [cloud_funtion_name].\nReconciling latest revision template. Resource readiness deadline exceeded.\n\n
Run Code Online (Sandbox Code Playgroud)\n

即使我删除并重新部署,也会发生这种情况。我检查了 StackOverFlow 和 Google Issue Tracker 上的几个线程,但似乎没有一个真正有帮助......

\n

有人有线索吗?如果需要更多信息,我很乐意处理。

\n

直到昨天下午,我都能够部署我的功能,没有任何形式的问题。\n但是一夜之间,就在昨天,我的部署开始失败,甚至更新也不再起作用。

\n

我其实是一无所知。 …

typescript gcloud gcloud-cli google-cloud-functions google-cloud-run

6
推荐指数
1
解决办法
2584
查看次数