Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 6. Composable Services
Red Hat OpenStack Platform now includes the ability to define custom roles and compose service combinations on roles (see "Composable Services and Custom Roles" in Advanced Overcloud Customization). As part of the integration, you can define your own custom services and include them on chosen roles. This section explores the composable service architecture and provides an example of how to integrate a custom service into the composable service architecture.
6.1. Examining Composable Service Architecture Copier lienLien copié sur presse-papiers!
The core Heat template collection contains a collection of composable service templates in the puppet/services subdirectory. You can view these services with the following command:
ls /usr/share/openstack-tripleo-heat-templates/puppet/services
$ ls /usr/share/openstack-tripleo-heat-templates/puppet/services
Each service template contains a description that identifies its purpose. For example, the keystone.yaml service template contains the following description:
description: > OpenStack Identity (`keystone`) service configured with Puppet
description: >
OpenStack Identity (`keystone`) service configured with Puppet
These service templates are registered as resources specific to a Red Hat OpenStack Platform deployment. This means you can call each resource using a unique Heat resource namespace defined in the overcloud-resource-registry-puppet.j2.yaml file. All services use the OS::TripleO::Services namespace for their resource type. For example, the keystone.yaml service template is registered to the OS::TripleO::Services::Keystone resource type:
grep "OS::TripleO::Services::Keystone" /usr/share/openstack-tripleo-heat-templates/overcloud-resource-registry-puppet.j2.yaml OS::TripleO::Services::Keystone: puppet/services/keystone.yaml
grep "OS::TripleO::Services::Keystone" /usr/share/openstack-tripleo-heat-templates/overcloud-resource-registry-puppet.j2.yaml
OS::TripleO::Services::Keystone: puppet/services/keystone.yaml
The overcloud.j2.yaml Heat template includes a section of Jinja2-based code to define a service list for each custom role in the roles_data.yaml file:
For the default roles, this creates the following service list parameters: ControllerServices, ComputeServices, BlockStorageServices, ObjectStorageServices, and CephStorageServices.
You define the default services for each custom role in the roles_data.yaml file. For example, the default Controller role contains the following content:
These services are then defined as the default list for the ControllerServices parameter.
You can also use an environment file to override the default list for the service parameters. For example, you can define ControllerServices as a parameter_default in an environment file to override the services list from the roles_data.yaml file.
6.2. Creating a User-Defined Composable Service Copier lienLien copié sur presse-papiers!
This example examines how to create a user-defined composable service and focuses on implementing a message of the day (motd) service. This example assumes the overcloud image contains a custom motd Puppet module loaded either through a configuration hook or through modifying the overcloud images as per Chapter 3, Overcloud Images.
When creating your own service, there are specific items to define in the service’s Heat template:
- parameters
The following are compulsory parameters that you must include in your service template:
-
ServiceNetMap- A map of services to networks. Use an empty hash ({}) as thedefaultvalue as this parameter is overriden with values from the parent Heat template. -
DefaultPasswords- A list of default passwords. Use an empty hash ({}) as thedefaultvalue as this parameter is overriden with values from the parent Heat template. -
EndpointMap- A list of OpenStack service endpoints to protocols. Use an empty hash ({}) as thedefaultvalue as this parameter is overriden with values from the parent Heat template.
Define any additional parameters that your service requires.
-
- outputs
The following output parameters define the service configuration on the host:
-
config_settings- Custom hieradata settings for your service. -
service_config_settings- Custom hieradata settings for another service. For example, your service might require its endpoints registered in OpenStack Identity (keystone). This provides parameters from one service to another and provide a method of cross-service configuration, even if the services are on different roles. -
global_config_settings- Custom hieradata settings distributed to all roles. step_config- A Puppet snippet to configure the service. This snippet is added to a combined manifest created and run at each step of the service configuration process. These steps are:- Step 1 - Load balancer configuration
- Step 2 - Core high availability and general services (Database, RabbitMQ, NTP)
- Step 3 - Early OpenStack Platform Service setup (Storage, Ring Building)
- Step 4 - General OpenStack Platform services
- Step 5 - Service activation (Pacemaker) and OpenStack Identity (keystone) role and user creation
In any referenced puppet manifest, you can use the
stephieradata (usinghiera('step')) to define specific actions at specific steps during the deployment process.upgrade_tasksand `upgrade_batch_tasks - Ansible snippet to help with upgrading the service. The snippet is added to a combined playbook. Each operation uses a tag to define a step, which includes:-
common- Applies to all steps -
step0- Validation -
step1- Stop all OpenStack services. -
step2- Stop all Pacemaker-controlled services -
step3- Package update and new package installation -
step4- Start OpenStack service required for database upgrade step5- Upgrade databaseThe
upgrade_batch_tasksperforms a similar function but only executes batch set of Ansible tasks in order they are listed. The default is1, but you can change this per role using theupgrade_batch_sizeparameter in aroles_data.yamlfile.
-
-
The following is an example Heat template (service.yaml) for the motd service:
- 1
- The template includes a
MotdMessageparameter used to define the message of the day. The parameter includes a default message but you can override it using the same parameter in a custom environment file, which is demonstrated later. - 2
- The
outputssection defines some service hieradata inconfig_settings. Themotd::contenthieradata stores the content from theMotdMessageparameter. ThemotdPuppet class eventually reads this hieradata and passes the user-defined message to the/etc/motdfile. - 3
- The
outputssection includes a Puppet manifest snippet instep_config. The snippet checks if the configuration has reached step 2 and, if so, runs themotdPuppet class.
6.3. Including a User-Defined Composable Service Copier lienLien copié sur presse-papiers!
The aim for this example is to configure the custom motd service only on our overcloud’s Controller nodes. This requires a custom environment file and custom roles data file included with our deployment.
First, add the new service to an environment file (env-motd.yaml) as a registered Heat resource within the OS::TripleO::Services namespace. For this example, the resource name for our motd service is OS::TripleO::Services::Motd:
Note that our custom environment file also includes a new message that overrides the default for MotdMessage.
The deployment will now include the motd service. However, each role that requires this new service must have an updated ServicesDefault listing in a custom roles_data.yaml file. In this example, we aim to only configure the service on Controller nodes.
Create a copy of the default roles_data.yaml file:
cp /usr/share/openstack-tripleo-heat-templates/roles_data.yaml ~/custom_roles_data.yaml
$ cp /usr/share/openstack-tripleo-heat-templates/roles_data.yaml ~/custom_roles_data.yaml
Edit this file, scroll to the Controller role, and include the service in the ServicesDefault listing:
When creating an overcloud, include the resulting environment file and the custom_roles_data.yaml file with your other environment files and deployment options:
openstack overcloud deploy --templates -e /home/stack/templates/env-motd.yaml -r ~/custom_roles_data.yaml [OTHER OPTIONS]
$ openstack overcloud deploy --templates -e /home/stack/templates/env-motd.yaml -r ~/custom_roles_data.yaml [OTHER OPTIONS]
This includes our custom motd service in our deployment and configures the service on Controller nodes only.