We will analyze the complete process of obtaining information from nova-api-metadata in detail through experiments. Instance
Environment Introduction
1. A All-in-one environment (multi-node similar).
2. Neutron network test_nethas been created and DHCP is started. In this metadata experiment, the type of test_net is not important, flat, VLAN, Vxlan can be.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082973876025308.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083737733017486.jpg "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
3. No neutron router.
Get ready and start experimenting.
Start instance
Deploy a instance with the Cirros image, namedC1, select Networktest_net。 During startup, review the startup log for instance.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082975424049583.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083737871060960.jpg "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
In the above log we see two messages:
①instance from DHCP to get the IP 17.17.17.5, this good understanding, because we open on the test_net DHCP service.
②instance will go to visit Http://169.254.169.254/2009-04-04/instance-id, tried 20 times have failed.
The Magical 169.254.169.254
What's the address of 169.254.169.254 ?
This is the IP of the metadata service.
This address is from AWS, when Amazon in the design of the public cloud, in order for instance to access metadata, will 169.254.169.254 this special IP as the metadata server address, instance boot Request metadata to 169.254.169.254 . This design was followed by OpenStack.
The problem we are facing now is that 169.254.169.254 can't access it! Cirros Cloud-init obviously did not get metadata, this point can at least from instance hostname not be set to C1 judged out.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082974633047336.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083738115081142.png "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
As we described in the Metadata Service architecture section above, instance first sends Metadata requests to the DHCP agent or L3_agent managed Neutron-ns-metadata-proxy. Who in the world is currently managing Neutron-ns-metadata-proxy? Let's take a look at the neutron-ns-metadata-proxy process on the control node first.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082974642022418.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083738253035138.jpg "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
Altogether no neutron-ns-metadata-proxy in operation!
The reason for this is that, by default, Neutron-ns-metadata-proxy is managed by L3_agent (which is discussed later to be managed by DHCP), because the current test_net is not hung on neutron router. So there is no boot neutron-ns-metadata-proxy.
Add Router
To solve this problem is simple: Create a virtual routerTest_routerand connecttest_net。
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082975434062037.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083738372089215.jpg "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
Now the control node has been able to see the test_router management of the Neutron-ns-metadata-proxy.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082976696082969.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083738644010588.jpg "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
Restart Instance C1to see how the changes will occur.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082977092095196.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083738876049382.jpg "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
Instance successfully accessed to 169.254.169.254. From the results, Cloud-init has been acquired to metadata, because hostname is already set to C1.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490082977082013220.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083739044015502.png "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
In the next section we analyze in detail how C1 got the metadata.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170314-1489480541786069813.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170321-1490083739160059618.jpg "style=" border:0px;margin:0px;padding:0px;float:none; Height:auto; "/>
Get a complete example of metadata-5 minutes a day to play with OpenStack (166)