是否可以在Google合作实验室中获取GCP的实例元数据? [英] Is it possible to obtain instance metadata for GCP on Google Collaboratory?

查看:59
本文介绍了是否可以在Google合作实验室中获取GCP的实例元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Google合作实验室上获取实例元数据.我有兴趣找出计算区域.

I'm trying to obtain instance metadata on Google Collaboratory. I'm interested in finding out the compute region.

具体地说,在Google合作实验室的托管运行时中,我尝试运行以下命令,但是它们超时了.

Specifically, on the hosted runtime on Google Collaboratory, I tried running the following commands but they time out.

!curl "http://metadata.google.internal/computeMetadata/v1/?recursive=true&alt=json" -H "Metadata-Flavor: Google"

curl: (7) Failed to connect to metadata.google.internal port 80: Connection timed out

!curl "http://169.254.169.254/computeMetadata/v1/instance/?recursive=true&alt=json" -H "Metadata-Flavor: Google"

curl: (7) Failed to connect to 169.254.169.254 port 80: Connection timed out

我做错了什么吗,还是有其他解决方法?

Am I doing something incorrectly, or are there any other workarounds for this?

谢谢!

推荐答案

您不能从Google Cloud Platform外部访问元数据服务器,因为它是Google Compute Engine(GCE)的特定功能.

you cannot access the metadata server from outside of Google Cloud Platform as it's something specific of the Google Compute Engine (GCE).

为了知道计算区域,您可以将Google Collaboratory笔记本与GCE中的实例VM链接在一起,然后您的笔记本将在该特定实例VM中运行.

In order to know the compute region you can link together your Google Collaboratory notebook with an instance VM in the GCE, then your notebook will run in that specific instance VM.

另一种方法是使用 AI平台笔记本代替Google协作,因为它使用GCE作为后端.

Another way is using the AI platform notebooks instead of Google Collaboratory, as this uses the GCE as a backend.

这篇关于是否可以在Google合作实验室中获取GCP的实例元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆