google-cloud-platform - 如何让 Google Cloud Run 使用 IPv4 而不是 IPv6 来容器应用

标签 google-cloud-platform google-cloud-run

我刚刚使用 Cloud Run 服务在 Google Cloud 上设置了一个基于 NodeJS 的网站。

有两个 DNS 记录:A (IPv4) 和 AAAA (IPv6)。每当我使用 Chrome 访问该网站时,我的 Chrome 都会选择 IPv6 地址,并且 NodeJS 应用程序会严重失败:

TypeError [ERR_INVALID_URL]: Invalid URL: http://2001:14ba:98ae:1700:****:****:****:****/
  at onParseError (internal/url.js:257:9)
  at new URL (internal/url.js:333:5)

注意:我审查了地址

如果我强制浏览器使用 IPv4 地址,则该网站可以正常工作。

有没有办法让 Cloud Run 服务对容器/应用程序使用 IPv4?我不介意 IPv6 client <-> Cloud Run级别。

我的 Cloud Run YAML 如下所示:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: xxx-dev-app-825af7f
  namespace: 'xxx'
  selfLink: /apis/serving.knative.dev/v1/namespaces/xxx/services/xxx-dev-app-825af7f
  uid: 2d787ef2-39a7-xxx-yyy-zzz
  resourceVersion: AAWfuzEBUYA
  generation: 5
  creationTimestamp: '2020-02-26T18:58:40.504717Z'
  labels:
    cloud.googleapis.com/location: europe-north1
  annotations:
    run.googleapis.com/client-name: gcloud
    serving.knative.dev/creator: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="58282d342d35311820202076313935763f2b3d2a2e313b3d393b3b372d362c763b3735" rel="noreferrer noopener nofollow">[email protected]</a>
    serving.knative.dev/lastModifier: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ae2e2e2daf9f6f5effef8eff3f6feb4fde9ffe8ecf3f9fffbf9f9f5eff4eeb4f9f5f7" rel="noreferrer noopener nofollow">[email protected]</a>
    client.knative.dev/user-image: gcr.io/xxx/app:4860b1e137457b0e42a1896d7b95e0348d8cd7e4
    run.googleapis.com/client-version: 279.0.0
spec:
  traffic:
  - percent: 100
    latestRevision: true
  template:
    metadata:
      name: xxx-dev-app-825af7f-00005-xoz
      annotations:
        run.googleapis.com/client-name: gcloud
        client.knative.dev/user-image: gcr.io/xxx/app:4860b1e137457b0e42a1896d7b95e0348d8cd7e4
        run.googleapis.com/client-version: 279.0.0
        autoscaling.knative.dev/maxScale: '1000'
    spec:
      timeoutSeconds: 900
      containerConcurrency: 80
      containers:
      - image: gcr.io/xxx/app:4860b1e137457b0e42a1896d7b95e0348d8cd7e4
        ports:
        - containerPort: 8080
        resources:
          limits:
            cpu: 1000m
            memory: 256Mi
          requests:
            cpu: 200m
            memory: 64Mi
status:
  conditions:
  - type: Ready
    status: 'True'
    lastTransitionTime: '2020-02-29T18:33:33.424Z'
  - type: ConfigurationsReady
    status: 'True'
    lastTransitionTime: '2020-02-29T18:33:28.264Z'
  - type: RoutesReady
    status: 'True'
    lastTransitionTime: '2020-02-29T18:33:33.424Z'
  observedGeneration: 5
  traffic:
  - revisionName: xxx-dev-app-825af7f-00005-xoz
    percent: 100
    latestRevision: true
  latestReadyRevisionName: xxx-dev-app-825af7f-00005-xoz
  latestCreatedRevisionName: xxx-dev-app-825af7f-00005-xoz
  address:
    url: https://xxx.run.app
  url: https://xxx.run.app

最佳答案

据我所知,IPv6 仅在全局负载均衡器上受支持。该负载均衡器代理连接并将其转换为 IPv4,以便内部访问 Google 网络。因此,使用 IPv6 直接访问 Cloud Run 似乎不可能。

但是,事情正在进展中,特别是在负载平衡方面,它可以解决您的问题。也许会在四月份的 Cloud Next 上发布公告。请继续关注!

关于google-cloud-platform - 如何让 Google Cloud Run 使用 IPv4 而不是 IPv6 来容器应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60468814/

相关文章:

java - Stackdriver Logback 附加程序停止应用程序

debian - sudoing 要求输入密码时的 Google Cloud VM

google-app-engine - 关于从伊朗访问谷歌云托管网站的任何建议

git - cloudbuild.yaml 包含不同的云构建器配置

google-cloud-platform - Cloud Run 已完成,但 Cloud Scheduler 认为作业失败

docker - `gcloud builds submit` 用于云运行

google-cloud-run - Cloud Run 是否支持服务器发送事件 (SSE)?

google-cloud-platform - 在哪里可以找到 Google 云平台 ID?

google-cloud-run - 谷歌云运行准备情况检查 - 如何?

docker - 上传docker镜像到google云平台 : https://grc. io/v2/: 服务不可用