Skip to content

Distribution

Distribution automatically manages application instances, controls the number of application instances and how they are distributed.

Before creating distribution, you need some information:

$ onteoncli application list
id                       createdAt                updatedAt                name                            version type     processType
6168227354b90d64e72d2280 2021-10-14T12:28:35.156Z 2021-10-14T12:28:35.156Z onteon-demo-app-cookbook-native 1.1.0   standard native

$ onteoncli script list
id                       createdAt                updatedAt                name                                         scriptType
6168216b54b90d64e72d21d7 2021-10-14T12:24:11.897Z 2021-10-14T12:24:11.897Z defaultAvailableNodeOnlyCINCANAIV1           check-if-node-can-accept-new-application-instance-v1
6168216b54b90d64e72d21d5 2021-10-14T12:24:11.892Z 2021-10-14T12:24:11.892Z defaultApplicationInstancesCountOnlySAITRV1  select-application-instance-to-remove-v1
6168216b54b90d64e72d21d3 2021-10-14T12:24:11.887Z 2021-10-14T12:24:11.887Z defaultApplicationInstancesCountOnlySNFNAIV1 select-node-for-new-application-instance-v1

Now you can create distribution. You can do this in two ways:

  • by specifying all information in command line. Read more
  • by distribution file - covered in this tutorial

Distribution file looks like this:

application: <application-id>
numberOfInstances: <number-of-application-instances>
scripts:
  checkIfNodeCanAcceptNewApplicationInstance: <name-of-script>
  selectNodeForNewApplicationInstance: <name-of-script>
  selectApplicationInstanceToRemove: <name-of-script>

Number of instances is a number of application instances that will be created after creating distribution.

Lets create distribution file for onteon-demo-app-cookbook-native application, with default scripts, with 2 instances.

application: 6168227354b90d64e72d2280
numberOfInstances: 2
scripts:
  checkIfNodeCanAcceptNewApplicationInstance: defaultAvailableNodeOnlyCINCANAIV1
  selectNodeForNewApplicationInstance: defaultApplicationInstancesCountOnlySNFNAIV1
  selectApplicationInstanceToRemove: defaultApplicationInstancesCountOnlySAITRV1

If you have your distribution file, you can create it by executing onteoncli distribution create-from-file <distribution-file>.

$ onteoncli distribution create-from-file distribution.yml 
id:                                                 6168269f54b90d64e72d2503
createdAT:                                          2021-10-14T12:46:23.765Z
updatedAt:                                          2021-10-14T12:46:23.765Z
applicationId:                                      6168227354b90d64e72d2280
numberOfInstances:                                  2
checkIfNodeCanAcceptNewApplicationInstanceScriptId: 6168216b54b90d64e72d21d7
selectNodeForNewApplicationInstanceScriptId:        6168216b54b90d64e72d21d3
selectApplicationInstanceToRemoveScriptId:          6168216b54b90d64e72d21d5

Then, watch how distribution creates new application instances by executing onteoncli application-instance list.

$ onteoncli application-instance list
id                       createdAt                applicationName                 applicationVersion applicationId            nodeId                   status
084283f5bcc72ce09b959e83 2021-10-14T12:46:39.112Z onteon-demo-app-cookbook-native 1.1.0              6168227354b90d64e72d2280 d816025d96da05df8463eebb running
ca978fac412796340499eda4 2021-10-14T12:46:31.829Z onteon-demo-app-cookbook-native 1.1.0              6168227354b90d64e72d2280 246eb1f89c2637d5b3cccda2 running
e1cd188353e6dbacf90d9be1 2021-10-14T12:24:20.86Z  nginx-edge                      1.0.0              null                     d816025d96da05df8463eebb running
f69972ba848290a4668cb191 2021-10-14T12:24:20.549Z nginx-edge                      1.0.0              null                     246eb1f89c2637d5b3cccda2 running
5caabcb26c1f5fa9c7e234b4 2021-10-14T12:24:19.801Z nginx-inner                     1.0.0              null                     d816025d96da05df8463eebb running
2900774056775fc37abbd0ea 2021-10-14T12:24:19.486Z nginx-inner                     1.0.0              null                     246eb1f89c2637d5b3cccda2 running

You can always change the number of instances by executing onteoncli distribution set-number-of-instances <distribution-id> <number-of-instances>.

$ onteoncli distribution list
id                       createdAt                updatedAt                applicationId            numberOfInstances
6168269f54b90d64e72d2503 2021-10-14T12:46:23.765Z 2021-10-14T12:46:23.765Z 6168227354b90d64e72d2280 2

$ onteoncli distribution set-number-of-instances 6168269f54b90d64e72d2503 4
id:                                                 6168269f54b90d64e72d2503
createdAT:                                          2021-10-14T12:46:23.765Z
updatedAt:                                          2021-10-14T12:49:07.111Z
applicationId:                                      6168227354b90d64e72d2280
numberOfInstances:                                  4
checkIfNodeCanAcceptNewApplicationInstanceScriptId: 6168216b54b90d64e72d21d7
selectNodeForNewApplicationInstanceScriptId:        6168216b54b90d64e72d21d3
selectApplicationInstanceToRemoveScriptId:          6168216b54b90d64e72d21d5

$ onteoncli application-instance list
id                       createdAt                applicationName                 applicationVersion applicationId            nodeId                   status
182e90ee9b406a1c9b7faa51 2021-10-14T12:49:17.428Z onteon-demo-app-cookbook-native 1.1.0              6168227354b90d64e72d2280 d816025d96da05df8463eebb running
ad63546b54c9175579a71c59 2021-10-14T12:49:10.098Z onteon-demo-app-cookbook-native 1.1.0              6168227354b90d64e72d2280 246eb1f89c2637d5b3cccda2 running
084283f5bcc72ce09b959e83 2021-10-14T12:46:39.112Z onteon-demo-app-cookbook-native 1.1.0              6168227354b90d64e72d2280 d816025d96da05df8463eebb running
ca978fac412796340499eda4 2021-10-14T12:46:31.829Z onteon-demo-app-cookbook-native 1.1.0              6168227354b90d64e72d2280 246eb1f89c2637d5b3cccda2 running
e1cd188353e6dbacf90d9be1 2021-10-14T12:24:20.86Z  nginx-edge                      1.0.0              null                     d816025d96da05df8463eebb running
f69972ba848290a4668cb191 2021-10-14T12:24:20.549Z nginx-edge                      1.0.0              null                     246eb1f89c2637d5b3cccda2 running
5caabcb26c1f5fa9c7e234b4 2021-10-14T12:24:19.801Z nginx-inner                     1.0.0              null                     d816025d96da05df8463eebb running
2900774056775fc37abbd0ea 2021-10-14T12:24:19.486Z nginx-inner                     1.0.0              null                     246eb1f89c2637d5b3cccda2 running

$ onteoncli distribution set-number-of-instances 6168269f54b90d64e72d2503 1
id:                                                 6168269f54b90d64e72d2503
createdAT:                                          2021-10-14T12:46:23.765Z
updatedAt:                                          2021-10-14T12:49:58.931Z
applicationId:                                      6168227354b90d64e72d2280
numberOfInstances:                                  1
checkIfNodeCanAcceptNewApplicationInstanceScriptId: 6168216b54b90d64e72d21d7
selectNodeForNewApplicationInstanceScriptId:        6168216b54b90d64e72d21d3
selectApplicationInstanceToRemoveScriptId:          6168216b54b90d64e72d21d5

$ onteoncli application-instance list
id                       createdAt                applicationName                 applicationVersion applicationId            nodeId                   status
ad63546b54c9175579a71c59 2021-10-14T12:49:10.098Z onteon-demo-app-cookbook-native 1.1.0              6168227354b90d64e72d2280 246eb1f89c2637d5b3cccda2 running
e1cd188353e6dbacf90d9be1 2021-10-14T12:24:20.86Z  nginx-edge                      1.0.0              null                     d816025d96da05df8463eebb running
f69972ba848290a4668cb191 2021-10-14T12:24:20.549Z nginx-edge                      1.0.0              null                     246eb1f89c2637d5b3cccda2 running
5caabcb26c1f5fa9c7e234b4 2021-10-14T12:24:19.801Z nginx-inner                     1.0.0              null                     d816025d96da05df8463eebb running
2900774056775fc37abbd0ea 2021-10-14T12:24:19.486Z nginx-inner                     1.0.0              null                     246eb1f89c2637d5b3cccda2 running