我只是使用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?我不介意client <-> Cloud Run
级别的IPv6。
我的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: pulumi@xxx.iam.gserviceaccount.com
serving.knative.dev/lastModifier: xxx@cloudbuild.gserviceaccount.com
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
答案 0 :(得分:1)
AFAIK,仅全局负载平衡器仅支持IPv6。该负载平衡器代理了该连接并将其转换为IPv4以供内部访问Google Network。因此,使用IPv6直接访问Cloud Run似乎是不可能的。
但是,事情正在进展中,尤其是在负载平衡方面,它可以解决您的问题。也许4月在Cloud Next上发布了消息。敬请期待!
答案 1 :(得分:1)
有关Cloud Run <=>用户浏览器之间的连接:您目前无法禁用IPv6堆栈。
(正如Guillaume所说,即将对可配置的Cloud HTTPS负载均衡器提供支持将解决您的问题-实际上,GCLB的默认设置是IPv4,如果您想为GCLB使用IPv6,则需要明确配置IPv6地址)。 / p>
用于Cloud Run Service之间的连接<=> Cloud Run Service::您应该完全控制客户端上要连接的IP。
例如,在客户端,
curl --ipv4
。