To allow you to build reusable applications and provide you with a self-service experience, CloudShell Colony includes some important features:
Sandbox Local DNS Service
CloudShell Colony configures a local DNS service in every sandbox. All applications and their addresses are registered in the sandbox DNS. This makes it easy to reach any application from every instance inside the sandbox using a custom DNS variable. This variable needs to be defined in the blueprint YAML and can then be passed to specific application YAMLs within the blueprint, and to those application's initialization.sh or start.sh scripts.
For example, in our WordPress application, we use MySQL as the backend server, which is deployed in the sandbox and may get different connectivity details in different sandboxes.
The WordPress Initialization script needs to configure the website's access to the database so instead of hard-coding it in the script or locating the correct IP address of the database, our Initialization script is using a custom input variable, which we declared in the blueprint YAML:
sed -i "s/localhost/$MY_SQL_DNS/g" wp-config.php
And here's the MY_SQL_DNS input declared in the blueprint YAML:
applications:
- wordpress:
instances: 2
input_values:
- INSTANCETYPE: $INSTANCETYPE
- MY_SQL_DNS: $colony.applications.mysql.dns
The Sandbox Discovery service translates the address $MY_SQL_DNS to the correct address of the MySQL Server.
NOTE: $colony.applications.mysql.dns is a reserved Colony input that must be set as a variable on the blueprint YAML. For details, see Blueprint YAML file's Inputs section.
User Input Parameters and Environment Variables
In CloudShell Colony, applications can declare input parameters. These parameters can either be provided during runtime by the user/CI build or be defined inside the blueprint's YAML. Using parameters is very handy for creating a self-service experience as it allows the application to declare a clear interface for all its consumers:
mysql.yaml
inputs:
- DB_USER: ''
- DB_PASS: ''
CloudShell Colony creates environment variables for all the parameters, which makes it easy to use parameters in scripts.
echo "mysql-server mysql-server/root_password password $DB_PASS" | debconf-set-selections echo "mysql-server mysql-server/root_password_again password $DB_PASS" | debconf-set-selections
In this example, the Initialization script uses the input parameters as Environment Variables by using the dollar sign $DB_PASS.
Referencing environment variables in scripts depends on the operating system script syntax.
Comments
0 comments
Please sign in to leave a comment.