当前位置:  开发笔记 > 编程语言 > 正文

将项目级元数据添加到Google云项目的最佳方法是什么?

如何解决《将项目级元数据添加到Google云项目的最佳方法是什么?》经验,为你挑选了1个好方法。

标签是项目级别的,具有字符限制,例如不能有空格。我可以通过bigquery表或在每台服务器上添加元数据。我还可以在默认的appspot存储桶上创建README.txt。

在项目级别添加元数据的最佳方法是什么?诸如项目内容,原因,负责人,利益相关者,开发人员,上下文/词汇之类的事情。例如,当我被解雇时,人们可以看到什么。



1> Lakshman Diw..:

存储元数据:

1.控制台

This is quite straightforward. Once you navigate to Metadata section under Compute Engine (Compute Engine > Metadata), you can add project-level key:value pair in the console.

2. gcloud

Type the following command in the cloud shell of the project.

gcloud compute project-info add-metadata --metadata projectMailID=abc@gmail.com

3. API

Sending a post request to the google API. This is usually a more manual task, where you need to make a GET first to get fingerprint and then post to the API using the fingerprint.

Querying Metadata:

1. curl or wget

This is the frequently used option for getting instance or project metadata.

curl "http://metadata.google.internal/computeMetadata/v1/project/" -H "Metadata-Flavor: Google"

The above command will list all the metadata associated with the given project. Metadata can be stored either in directory or a single entry. If the URL ends in /, then it lists the directory, else it shows the value of single entry key.

The custom-metadata are stored under attributes directory. This can be retrieved by:

curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/" -H "Metadata-Flavor: Google"

The above command lists all custom entries made in the project. To get the value of a single entry, try this:

curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/ProjectMailID" -H "Metadata-Flavor: Google"

Metadata-Flavor: Google

This header indicates that the request was sent with the intention of retrieving metadata values, rather than unintentionally purposes.

2. gcloud

The gcloud command will list all metadata and other information about the project.

gcloud compute project-info describe

3. API

Making a GET request to the API will do the equivalent of gcloud.

GET https://www.googleapis.com/compute/v1/projects/

Additional Information:

Waiting For Updates

This option allows to wait for any changes to the metadata and then retrieve the updated value. This can be done by appending ?wait_for_change=true as query parameter.

curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/?wait_for_change=true" -H "Metadata-Flavor: Google"

Recursive

This option is used to print recursively the entries in the directory. This can be done by appending ?recursive=true as query parameter.

curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/?recursive=true" -H "Metadata-Flavor: Google"

推荐阅读
wangtao
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有