Configure instance metadata
The Compute (nova) service uses metadata to pass configuration information to instances on launch. The instance can access the metadata by using a config drive or the metadata service.
- Config drive
- By default, every instance has a config drive. Config drives are special drives that you can attach to an instance when it boots. The config drive is presented to the instance as a read-only drive. The instance can mount this drive and read files from it to get information that is normally available through the metadata service.
- Metadata service
- The Compute service provides the metadata service as a REST API, which can be used to retrieve data specific to an instance. Instances access this service at
169.254.169.254or atfe80::a9fe:a9fe.
Types of instance metadata Copy linkLink copied!
Cloud users, cloud administrators, and the Compute service can pass metadata to instances:
- Cloud user provided data
- Cloud users can specify additional data to use when they launch an instance, such as a shell script that the instance runs on boot. The cloud user can pass data to instances by using the user data feature, and by passing key-value pairs as required properties when creating or updating an instance.
- Cloud administrator provided data
-
The Red Hat OpenStack Services on OpenShift (RHOSO) administrator uses the vendordata feature to pass data to instances. The Compute service provides the vendordata modules
StaticJSONandDynamicJSONto allow administrators to pass metadata to instances:StaticJSON: (Default) Use for metadata that is the same for all instances.DynamicJSON: Use for metadata that is different for each instance. This module makes a request to an external REST service to determine what metadata to add to an instance.
Vendordata configuration is located in one of the following read-only files on the instance:
-
/openstack/{version}/vendor_data.json -
/openstack/{version}/vendor_data2.json
- Compute service provided data
- The Compute service uses its internal implementation of the metadata service to pass information to the instance, such as the requested hostname for the instance, and the availability zone the instance is in. This happens by default and requires no configuration by the cloud user or administrator.
Disable config drive Copy linkLink copied!
To disable the attachment of a config drive when launching an instance, you must set the force_config_drive parameter to false.
Before you begin Copy linkLink copied!
- The
occommand line tool is installed on your workstation. - You are logged in to Red Hat OpenStack Services on OpenShift (RHOSO) as a user with
cluster-adminprivileges. - You have selected the
OpenStackDataPlaneNodeSetcustom resource (CR) that defines the nodes for which you want to disable config drive. For more information about creating anOpenStackDataPlaneNodeSetCR, see Create an OpenStackDataPlaneNodeSet CR with pre-provisioned nodes.
About this task Copy linkLink copied!
Procedure Copy linkLink copied!
Configure dynamic metadata for instances Copy linkLink copied!
Configure dynamic metadata to provide instance-specific metadata generated by an external service. Instances access metadata through the config drive and metadata service. Configure both data plane and control plane to ensure consistent content across access methods.
Before you begin Copy linkLink copied!
- The
occommand line tool is installed on your workstation. - You are logged in to Red Hat OpenStack Services on OpenShift (RHOSO) with
cluster-adminprivileges. - You have selected the
OpenStackDataPlaneNodeSetcustom resource (CR) that defines the nodes for which you want to configure dynamic metadata. For more information about creating anOpenStackDataPlaneNodeSetCR, see Create a data plane for dynamic routing. - The external http service is accessible from both the control plane and data plane Compute nodes.
Procedure Copy linkLink copied!
-
Configure the data plane:
-
Configure the control plane:
Results Copy linkLink copied!
- Create a new instance:
$ openstack server create --flavor <flavor> --image <image> --nic <nic> --use-config-drive vm1 - Use a remote console or SSH to access the instance. Within the instance, use one of the following methods to query the dynamic metadata:
- The metadata service from the address
http://169.254.169.254/openstack/latest/vendor_data2.json, for example:$ curl http://169.254.169.254/openstack/latest/vendor_data2.json {"target1": {...}, "target2":{...}} - The config drive by mounting the extra disk drive provided to the instance and accessing the file
openstack/latest/vendor_data2.jsonon it, for example:$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 474K 0 rom vda 252:0 0 1G 0 disk |-vda1 252:1 0 1015M 0 part / `-vda15 252:15 0 8M 0 part vdb 252:16 0 1G 0 disk /mnt$ mkdir /tmp/conf $ mount /dev/sr0 /tmp/conf $ cat /tmp/conf/openstack/latest/vendor_data2.json {"target1": {...}, "target2":{...}}The control plane is deployed when all the pods are either completed or running.
- The metadata service from the address