Instance metadata provides basic VCI information, such as the instance hostname, instance ID, instance specifications, region, and availability zone. This topic describes how to query instance metadata.
Usage notes
Metadata of an instance can be accessed only from within the instance. The metadata is not encrypted or protected, and anyone who can access the instance can query its metadata. If the metadata contains sensitive information, you should take appropriate measures to protect the sensitive data, such as limiting the scope of access and encrypting the metadata.
Prerequisites
Querying instance metadata
Access method description
You can query instance metadata by using the cURL tool or an HTTP GET request. The query format is http://100.96.0.96/latest/${metadata}.
tip
- Replace ${metadata} with a specific instance metadata item. For example, to query metadata item instance_id, use http://100.96.0.96/latest/instance_id.
Step 1: Log in to the instance
To perform instance metadata operations, you must first log in to the target instance. This topic describes how to log in to a VCI by using a Deployment as an example.
- Go to the management page of the Deployment.
- In the left navigation bar, click Cluster.
- In the cluster list, click the target cluster that runs the VCI application.
- In the left navigation bar of the cluster management page, click Workload > Deployment.
- Click the name of the target Deployment to go to the its page.
- On the Deployment page, click Console in the upper-right corner to log in to the VCI pod.
Step 2: Query metadata
For example, after logging in to the VCI pod, you can run the following shell command to query instance metadata by using cURL:
tip
Ensure that the cURL tool is installed in the container image. If it is not installed, install it first.
- Query the root directory for instance metadata:
- Query the billing type of the instance:
- Query IAM roles of the instance: