Environment Creation

CLI Tutorial: Environment Creation

Creating environments through the command line is useful for repeatable infrastructure tasks, automated deployments, and more complex DevOps workflows.

Create an Environment with CLI Parameters

The most direct method is to provide the environment and node parameters in the createenvironment command.

~/jelastic/environment/control/createenvironment --env '{"shortdomain" : "{env_name}", "engine" : "{engine_type}"}' --nodes '[{"nodeType" : "{node_type}", "fixedCloudlets" : {cloudlets_amount}, "flexibleCloudlets" : {cloudlets_amount}}]'
{env_name}Name of the new environment.
{engine_type}Engine used by the environment.
{node_type}Identifier of the required software stack.
{cloudlets_amount}Number of fixed and flexible Cloudlets assigned to the node.
Create an environment with the platform CLI
Run createenvironment with the required environment and node parameters.
A CLI response with "result": 0 means that the operation completed successfully without errors.

Create an Environment from a JSON File

For reusable configurations, store the complete environment topology in a JSON file. The same file can then be used repeatedly without entering all parameters for every deployment.

{
  "env": {
    "shortdomain": "{env_name}",
    "engine": "{engine_type}"
  },
  "nodes": [
    {
      "nodeType": "{node_type}",
      "fixedCloudlets": "{cloudlets_amount}",
      "flexibleCloudlets": "{cloudlets_amount}"
    }
  ]
}

After replacing the placeholders, run the environment-creation method with the --myparams option:

~/jelastic/environment/control/createenvironment --myparams {path_to_file}

Provide the full path to the JSON file, or only its filename when it is stored in the user’s home directory.

Override JSON Environment Settings

The reusable JSON topology can be combined with command-line values that override or add selected environment settings.

  • shortdomain
  • region
  • displayName

For example, overriding shortdomain allows the same JSON topology to create another environment under a different name.

Create an environment from JSON and override the name
Reuse a JSON topology while overriding selected environment settings.

Create a Docker-Based Environment

A Docker-based environment uses a similar command but requires the Docker node type and image information.

~/jelastic/environment/control/createenvironment --env '{"shortdomain" : "{env_name}"}' --nodes '[{"nodeType" : "docker", "fixedCloudlets" : {cloudlets_amount}, "flexibleCloudlets" : {cloudlets_amount}, "docker" : {"image" : "{image_name}"}}]'
  • Set nodeType to docker.
  • Replace {image_name} with the Docker image address.
  • A full image address can follow the format server.com/images/image_name:tag.
  • For an image from the public Registry Hub, the registry hostname can be omitted.
  • The version tag after : is optional.
  • For a private registry, add a registry parameter containing its URL, username, and password.
Create a Docker-based environment with CLI
Create a Docker container by providing its image and resource settings.
Private registry: Keep registry credentials secure and avoid exposing passwords in shared scripts, shell history, or public repositories.

What’s next?