Scaling a component

Scaling the component of an assembly is a pattern that either adds or removes a component instance from a scaling group (including all relationships).

Before you begin

  • Create the test_1 example assembly instance, which is described in Creating an assembly instance.
  • The assembly to which the component belongs must be instantiated in the orchestration topology, and be in the 'Active state'.
  • A cluster definition for the component itself must exist in the assembly descriptor, in which the minimum and maximum size of the scaling group and the default increment when scaling out or in are also defined.

About this task

You scale assembly instance components by using the Intents API. For more information about this API, see Intents API.

Assembly descriptors are in the orchestration component catalog, which you can view by using the Descriptors API .

For this task, you use component B, which is part of the t_bta assembly (assembly::t_bta::1.0).

The cluster definition for component B is depicted in the following sample:
…
composition:
  A:
    type: resource::t_simple::1.0
    quantity: '1'
…
  B:
    type: resource::t_simple::1.0
    cluster:
      initial-quantity: '${numOfServers}'
      minimum-nodes: 1
      maximum-nodes: 4
      scaling-increment: 1
    properties:
 …

Procedure

  1. To identify the name of the component of the test_1 assembly to be scaled, you can query the assembly topology through the Assemblies API by using the following GET command:
    GET /api/v1/topology/assemblies?name=test_1
    The query returns the assembly topology information, which includes the descriptorName, as depicted in the following sample:
    "type": "Assembly"
      "id": "bf649336-c8c5-49d9-9f4e-60567fe54135",
      "name": "test_1",
      "state": "Active",
      "descriptorName": "assembly::t_bta::1.0",
      "properties": [
        {
    …
    
  2. Retrieve the descriptor from the orchestration catalog by running the following query on the Descriptors API using the descriptorName obtained in the previous step:
    GET /api/v1/catalog/descriptors/assembly::t_bta::1.0
    The scaling group definition for B is shown in the following sample.
    …
    composition:
      A:
        type: resource::t_simple::1.0
        quantity: '1'
    …
      B:
        type: resource::t_simple::1.0
        cluster:
          initial-quantity: '${numOfServers}'
          minimum-nodes: 1
          maximum-nodes: 4
          scaling-increment: 1
        properties:
     …
    
    Here one instance of B is created when an instance of the assembly is created. By scaling Out or In, the amount of B instances can be changed between one and four. As the increment is defined as one, each scale out or scale in pattern will increase or decrease the amount of B instances by one.
  3. To scaleOut, that is to add another instance of resource B to test_1, use the swagger-url for the Daytona service, using the following POST command:
    You can use either the assemblyName or assemblyId to initiate the 'Scale Out' pattern.
    POST /api/v1/intent/scaleOutAssembly
    {
      "assemblyName": "test_1",
      "clusterName": "test_1__B"
    }
    
    Or:
    POST /api/v1/intent/scaleOutAssembly
    {
      "assemblyId": "ef4ea879-e313-4e3b-ad11-6a0a7e7544eb",
      "clusterName": "test_1__B"
    }
    
    The clusterName identifies the group of resources to be scaled (B), increasing the amount of B instances by one unless the maximum scaling group size (in this case four) has been reached.
  4. To scaleIn, that is to reduce the instances of resource B, use the following POST command:
    You can use either the assemblyName or assemblyId to initiate the 'Scale In' pattern.
    POST /api/v1/intent/scaleInAssembly
    {
      "assemblyName": "test_1",
      "clusterName": "test_1__B"
    }
    
    Or:Here the group of B resources are decreased by one, unless the minimum scaling group size (in this case one) has been reached.
  5. To check the status of the assembly after scaling, query the assembly topology using the following GET command:
    GET /api/v1/topology/assemblies?name=test_1
    The assembly topology will depict all the instances of component B and the relationships towards the new resource instances.

Results

When viewing the topology after running ScaleOut, a new instance of B will be depicted called test_1__B__2, as well as a new relationship between it and the existing test_1__A instance.