Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does instance get his own Metadata?

Shulou Source: shulou.com Published: 2022-06-01 00:44:00 10月06日 Update

Today, I will talk to you about how instance gets its own Metadata. Many people may not know much about it. In order to make you understand better, the editor summed up the following content for you. I hope you can get something according to this article.

To get the metadata from nova-api-metadata, you need to specify the id of the instance. However, instance cannot know its id when it is started, so there is no instance id information in the http request. Id is added by neutron-metadata-agent. In view of the differences in implementation details between l3-agent and dhcp-agent, they are discussed below.

L3-agent

Process: instance-> neutron-ns-metadata-proxy-> neutron-metadata-agent-> nova-api-metadata. The processing details are as follows:

① neutron-ns-metadata-proxy receives the request and adds instance ip and router id to the head of the http request before forwarding it to neutron-metadata-agent, which is easily available to l3-agent.

When ② neutron-metadata-agent receives the request, it queries the id of instance by:

1) find all the subnet connected to the router through router id, and then filter out the subnet where the instance ip is located.

2) find the port corresponding to instance ip in subnet.

3) find the corresponding instance and its id through port.

③ neutron-metadata-agent adds instance id to the head of the http request and forwards it to nova-api-metadata so that nova-api-metadata can return the metadata of the specified instance.

Let's take a look at dhcp-agent.

Dhcp-agent

① neutron-ns-metadata-proxy adds instance ip and network id to the head of the http request before forwarding the request, which is easily available to dhcp-agent.

When ② neutron-metadata-agent receives the request, it queries the id of instance by:

1) find all the subnet of network through network id, and then filter out the subnet where the instance ip is located.

2) find the port corresponding to instance ip in subnet.

3) find the corresponding instance and its id through port.

③ neutron-metadata-agent adds instance id to the head of the http request and forwards it to nova-api-metadata so that nova-api-metadata can return the metadata of the specified instance.

In this way, whether instance sends the request to l3-agent or dhcp-agent,nova-api-metadata will eventually know the id of instance and return the correct metadata.

From the point of view of the process of obtaining the metadata, one step is crucial: the instance must first be able to get the DHCP IP correctly, otherwise the request will be sent less than 169.254.169.254. But not all environments will enable dhcp, and more extreme, some environments may not even enable nova-api-metadata services.

After reading the above, do you have any further understanding of how instance gets its own Metadata? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Information content two practice situation location process environment details selection query different important by more different extreme knowledge article crucial Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Docker OPPO Reno Shulou Information