Play with OpenStack instance metadata
Nova API metadata.
I. Reminder
First check the OpenStack official documentation about the metadata service. Metadata Ideally if you run an OpenStack production environment you will opt for a multi compute node solution which requires nova metadata service on each nova-compute node (for performance purpose). You can assign the metadata server like so:
- Use the
metadata_host
option in nova.conf, specify the IP address of the node running nova-api - Run the nova-api service on each nova-compute node and specify the
enabled_apis = metadata
flag in nova.conf - Or the last option (my favorite), simply run the nova-api-metadata (with the same name package) service on each nova-compute node. It doesn’t require any modification in nova.conf (default options are enough)
Flags related to metadata in nova.conf:
- metadata_listen_port = 8775
- metadata_host = 172.17.1.3
- metadata_manager = nova.api.manager.MetadataManager
- quota_metadata_items = 128
- metadata_listen = 0.0.0.0
- enabled_apis = [‘ec2’, ‘osapi_compute’, ‘osapi_volume’, ‘metadata’]
- metadata_port = 8775
The cloud-init service hosted inside each cloud-image retrieves the metadata during the boot sequence. Metadata contains a lot of information related to the running instance. For example ssh keys will be injected in order to access the virtual instance (always during the boot sequence).
II. Play!
First pick up an instance and ssh into it. You’r ready to retrieve the metadata, you can use both wget
or curl
. I have a preference for curl
because it shows the content and doesn’t download it immediately:
$ curl http://169.254.169.254/latest/meta-data/ |
Try to download the ssh public key:
$ curl http://169.254.169.254/latest/meta-data/public-keys//0/openssh-key -O |
That’s all!
Comments