Create service
This page assumes that you have already created and selected an environment.
Service type
You can choose to deploy a service from the marketplace or from a docker image.
LayerOps seamlessly integrates with both private and public Docker repositories (for more details, please refer to the registry documentation).
Docker configuration
You can choose to use a private registry (see how to add a private registry) or the default registry (https://hub.docker.com/).
Ports
Services can listen on specific ports, and you have the option to set up load balancer rules to make them public or keep them strictly private within your environment, accessible only to other services.
To add one or more ports click on "Add port" button. You can now define the port on which your service listens.
If you want your service to be accessible from the internet, check the "Add load balancer rule" option.
If you have already defined custom domains, you can enter them here, to make this service and port accessible at this address.
This rule can be edited or added later from load balancer routing rules.
Health check
Health check help LayerOps determine when a service is available to receive traffic. While health checks are optional, they play a crucial role in ensuring the availability and reliability of your services.
Resource requirements
By defining the necessary resources (CPU and RAM) for your service, you enable us to efficiently allocate and distribute your services across your instances, ensuring optimal performance and functionality.
Later, if you enable autoscaling, we will use this information to increase or decrease the number of copies of this service according to the consumption.
Quantity (and autoscaling)
In the "quantity" section, you can fine-tune the deployment of your services. You can opt to specify a fixed quantity of services to deploy, or you can enable autoscaling for dynamic adjustments based on your service's demand.
With autoscaling, you can set both minimum and maximum service quantities. This allows you to maintain control over your resources while ensuring that your services can adapt to fluctuating workloads.
Additionally, you can configure autoscaling rules based on CPU and RAM utilization, determined as a percentage of the values you specified in "Resource Requirements".
Deployment constraints
This option can be added once all the required steps have been completed. You will find this option under "Something more?".
Within the "Deployment Constraints" section, you configure where your service is deployed.
- You can choose one or more tags. By defining a tag, your service will be deployed on an instance pool configured with that tag, streamlining and optimizing the deployment process to meet your exact requirements.
- You can choose a specific provider, which is useful when you need to specify a particular region or cloud infrastructure.
- You can select a particular instance pool, ensuring your service runs on one of the instances within that pool.
You can also provide several constraints.
Link to other services
This option can be added once all the required steps have been completed. You will find this option under "Something more?".
The "Service Relations" feature allows communication between services within your environment. You can define a service and its associated port that your service needs to communicate with.
Once you've set up the service relationship, you can specify which environment variable LayerOps should inject with the relevant information about this related service. Here are the variables that LayerOps will inject:
- Host: Information about the host of the related service. For instance, this might be an IP address like 127.0.0.1.
- Port: The port of the related service, like 80.
- Address: The complete address of the related service, like 127.0.0.1:80.
Service relation example
To establish communication with a service like MySQL, you first define that service within the relations. Then, you specify the relevant information, such as the host (e.g., MYSQL_HOST), port (e.g., MYSQL_PORT), and address (e.g., MYSQL_ADDR).
Within your service, when you need to connect to MySQL, you can utilize these predefined variables to ensure proper communication with the MySQL service.
Then in your service you can execute commands like:
mysql --host=$MYSQL_HOST --port=$MYSQL_PORT
Volumes
This option can be added once all the required steps have been completed. You will find this option under "Something more?".
Environment variables
This option can be added once all the required steps have been completed. You will find this option under "Something more?".
CRON
This option can be added once all the required steps have been completed. You will find this option under "Something more?".
Additionally, services can have a CRON configuration, enabling you to specify when a service should be started.
Side task
This option can be added once all the required steps have been completed. You will find this option under "Something more?".
Schedule
This option can be added once all the required steps have been completed. You will find this option under "Something more?".
Furthermore, services can be scheduled to start and stop at specific times, and you can establish plans for changing scaling rules. Read more about schedule configuration.