Specifying the cloud-init data to grow an LVM-based VCP node

Specifying the cloud-init data to grow an LVM-based VCP nodeΒΆ

When a VM is spawned, the cloud-init growroot module extends the physical disk to consume all free space. The stages of the partition growth for a VCP node with Logical Volume Management (LVM) include:

  1. The growth of a physical disk, which is performed by the growroot module.

    To grow a particular physical drive and not the / mounpoint as it is pointed to LVM, you need to pass the following cloud_init data to the cluster level:

    _param:
      salt_control_cluster_vcp_lvm_device: '/dev/vda3'
    salt:
      control:
        cluster:
          internal:
            seed: cloud-init
            cloud_init:
              user_data:
                growpart:
                  mode: auto
                  devices:
                  - '/'
                  - ${_param:salt_control_cluster_vcp_lvm_device}
                  ignore_growroot_disabled: false
    

    Note

    The name of the disk can differ depending on the VCP disk driver. By default, vda as virtio is used.

  2. The extension of the LVM physical volume to consume all free disk space.

    Configuration example:

    _param:
       salt_control_cluster_vcp_lvm_device: '/dev/vda3'
     salt:
       control:
         cluster:
           internal:
             seed: cloud-init
             cloud_init:
               user_data:
                 runcmd:
                   - 'if lvs vg0; then pvresize ${_param:salt_control_cluster_vcp_lvm_device}; fi'
                   - 'if lvs vg0; then /usr/bin/growlvm.py --image-layout-file /usr/share/growlvm/image-layout.yml; fi'
    
  3. The application of the partitioning layout.

    The partitioning layout is stored in salt:control:size:openstack.control:image_layout, which is a dictionary with the following schema:

    {"$schema": "http://json-schema.org/draft-04/schema#",
     "title": "Image partition layout",
     "type": "object",
     "patternProperties": {
         ".*": {"$ref": "#/definitions/logical_volume_layout"}
     },
     "definitions": {
         "logical_volume_layout": {
             "type": "object",
             "properties": {
                 "name": {
                     "description": "Logical Volume Name",
                     "type": "string"
                 },
                 "size": {
                     "description": (
                         "Size of Logical volume in units of logical extents. "
                         "The number might be volume size in units of "
                         "megabytes. A size suffix of M for megabytes, G for "
                         "gigabytes, T for terabytes, P for petabytes or E for "
                         "exabytes is optional. The number can also be "
                         "expressed as a percentage of the total space in the "
                         "Volume Group with the suffix %VG. Percentage of the "
                         "changeble values like free space is not supported."
                         ),
                 },
                 "resizefs": {
                     "description": (
                         "Resize underlying filesystem together with the "
                         "logical volume using fsadm(8)."
                     ),
                     "type": "boolean"
                 },
                 "vg": {
                     "description": ("Volume group name to resize logical "
                                     "volume on."),
                     "type": "string"
                 }
             },
             "additionalProperties": False,
             "required": ["size"]
         }
     }}
    

    The default partitioning layout is specified in the /srv/salt/reclass/classes/system/defaults/salt/init.yml file.

    Configuration example:

    parameters:
      _param:
        salt_control_size_image_layout_default:
          root:
            size: '30%VG'
          home:
            size: '1G'
          var_log:
            size: '11%VG'
          var_log_audit:
            size: '5G'
          var_tmp:
            size: '11%VG'
          tmp:
            size: '5G'
        salt_control_size_image_layout_ceph_mon: ${_param:salt_control_size_image_layout_default}
        salt_control_size_image_layout_ceph_rgw: ${_param:salt_control_size_image_layout_default}
    

    You can adjust the partitioning layout for a particular size through a soft type parameter. For example, you can describe the partitioning layout for ceph.mon as follows:

    parameters:
      _param:
         salt_control_size_image_layout_ceph_mon:
           root:
             size: '70%VG'
           home:
             size: '500M'
           var_log:
             size: '5%VG'
           var_log_audit:
             size: '1G'
           var_tmp:
             size: '1G'
           tmp:
             size: '1G'