In this tutorial we add a new parameter to node requests in order to be able to deploy them on a specific computer.
For production services, control is needed on where the instances are deployed. In the past tutorial, the request are done without specifying any SLA or server, so the SlapOS master will allocate the instance on any server with availability and the software release. SlapOS allows to specify SLA parameters, including the specific identifier of the SlapOS Node on where the service is to be deployed. When developing instances that will be deployed on multiple servers, it is necessary to include the possibility for the requester to specify where it whishes to deploy its service.
Here is the commit introducing this functionality to html5as Software release:
Edit instance_replicate.cfg.in
. Extend the [instance-{{i}}]
section to include optional sla-parameter
computer_guid
. So if we want to deploy instance-1 on the node "COMP-1234", the service must be requested with the parameter: sla-1-computer-guid=COMP-1234
{% for i in range(1, replicate_quantity + 1) %}
# Request a normal html5as instance
[instance-{{ i }}]
...
{% if "sla-%s-computer-guid" % i in parameter_dict -%}
sla-computer_guid = {{ parameter_dict["sla-%s-computer-guid" % i] }}
{% endif -%}
...
Refer How To Move to md5sum automatic update to update md5sum
:
$ cd ~/srv/project/slapos/software/html5as-base $ ../../update-hash
sla-1-computer-guid=slaprunner
To request a replicate type of sofware, you should define the type in the request script:
slapos request $software_name-1 $software_release_uri --type="replicate" --parameters replicate-quantity=3 sla-1-computer-guid=slaprunner
Make sure to edit it in your request file instead of the example one. Parameters like replicate-quantity
, title
, etc. should place after --parameters
directly as shown in the screenshot.
Run the request script by
$ cd ~/srv/project/slapos/software/html5as-base
$ bash ../../../request-html5as-base.sh
Refer How To Inspect Logs In Rapid.Space Theia Runner to verify:
$ tail -f ~/srv/runner/var/log/slapos-node-software.log
$ tail -f ~/srv/runner/var/log/slapos-node-instance.log
There is no errors expected. The compiling and instantiation should be completed.
Let's check if the parameter sla-1-computer-guid
has been rendered:
$ cd ~/srv/runner/instance/ $ grep sla-computer_guid slappart*/buildout*.cfg
The output should be:
slappart0/buildout-switch-softwaretype.cfg:sla-computer_guid = slaprunner
The value of sla-1-computer-guid
, slaprunner
has been taken into account.
For more information, please contact Jean-Paul, CEO of Nexedi (+33 629 02 44 25).