Services

In this article


Overview

Services run as containers in your cluster that are orchestrated by Docker. There are two types of services that are orchestrated in MedStack Control.

  1. Managed services
  2. Custom services

You'll be able to interact with these services by navigating into the cluster by clicking the arrow next to the cluster name.

All services, both managed and custom, will appear in a list within the Services tab.

Managed services

MedStack has provisioned managed services so you may run in your cluster in a HIPAA compliant manner. These types of services are turnkey solutions that add desirable functionality to your cluster.

These kinds of services can be managed in your cluster and run in containers. The configuration of managed services are often abstracted to the user by design, making them convenient turnkey solutions to run them in your cluster. 

Create

To create a managed service within a cluster:

  1. Click the "NEW SERVICE" button within the Services tab in the desired Cluster.
  2. Select the desired managed service from the tiles available in the "New managed service" section.

For a complete list of the managed services supported on MedStack, check out our Managed services collection in our support documentation.

Delete

There are two methods to delete a managed service from your cluster:

Method 1

  1. Navigate to the cluster's Services tab.
  2. Click the name of the managed service you'd like to update

Method 2

  1. Navigate to the cluster's Services tab.
  2. Click the "Options" selector button for the service you'd like to delete.
  3. Select the option to "Show"
  4. Click the button to "DELETE" the service.

Custom services

In almost every case, our users are leveraging custom services to run their cloud applications. Custom services are containerized images that can be ran on Docker.
Most users are running a combination of public and private images, which enables teams to quickly adopt community maintained images like those hosted on DockerHub along side their private images.

You'll be able to create, update and delete services in your cluster. When managing your custom services, you'll have control over some essential parameters:

Create

Image

There are two types of images that a user may configure in their services, they are:

  1. Images on public registries
  2. Images on private registries
Public registries

Since PostgreSQL 9.6 is available on the public Docker Hub registry, you can specify just the image name and tag to indicate the service image in MedStack Control. This applies for any service image on MedStack Control, where you can specify the image name and tag for any service hosted on the public Docker Hub.

image: "postgres:9.6"
Private registries

For users with private image registries, you will need to specify the image by its (1) domain, (2) path, and (3) tag. Furthermore, each MedStack user managing a service must have the proper registry credentials to access a private registry. See add registry credentials for more information on this process.

image: "registry.gitlab.com/medstack-inc/flask-demo:1.0"registry.hub.docker.com

The image must be accessible from a registry to which the MedStack Control user has access. Users can add registry credentials to their accounts from the cluster management page. It is important to note that registry credentials are per user, not per organization, thus each MedStack Control user will need to registry credentials to their user account.

Note, if you are using a private Docker Hub registry, your service will be available at the following path:

image: "registry.hub.docker.com/<library>/<image>"

Replicas

The replica count indicates the number of containers running a service on your infrastructure. Increasing and decreasing the replica count is synonymous with manual horizontal scaling of services. In summary, the following explains how replicas correlate to containers:

// No containers running the service; the service is not available on the cluster
replicas: 0

// 1 container; the service is available on the cluster with no redundancy
replicas: 1

// 2 containers; the service is available on the cluster with 1 degree of redundancy
replicas: 2

It is important to note that users should avoid redundant replicas for stateful services, meaning, it is not advised to configure a stateful service (like a database) with 2 or more replicas.

Runtime commands

You can configure a service to run commands upon its initialization in by clicking the "SHOW ADVANCED OPTIONS" beneath the "Replicas" field.

The resulting command and arguments field are used for running docker service child commands.

Domain mapping

Commonly known as ingress, domain mapping is a service configuration where a service's domain and port can be specified.
It is important to note that domain mapping is only available once MedStack's load balancer managed service is running on your cluster. See here for more information on adding the load balancer service. For example, image a user is configuring two services, "Service A" and "Service B", the following could be the case to make each service available from different subdomains.

// Service A configuration
// Domain mapping
domain: "accounts.myapplication.com"
port: 80

// Service B configuration
// Domain mapping
domain: "dashboard.myapplication.com"
port: 80

Environment variables

These are service-specific key value pairs you can configure for the service to behave as intended. It is good practice to manage environment variables from a configurable as in MedStack Control rather than hardcoding the environment variables into the service image itself.

In order to add an environment variable:

  1. Click the "ADD ENVIRONMENT VARIABLE" button.
  2. Add the key value pair to the respective fields.
  3. If you'd like to add another environment variable, you can click the "ADD ENVIRONMENT VARIABLE" button again.

To remove an environment variable, simply click the "REMOVE" button next to the key value pair you'd like to remove.

Configs

These configs must be created at a cluster level. Once this has been done, they can be used by the service.

Secrets

These secrets must be created at a cluster level. Once this has been done, they can be used by the service.

Volumes

These volumes must be mapped at a cluster level. Once this has been done, they can be used by the service.It is important to note that volumes are mapped at a cluster level; however, the physical storage of stateful data will exist on the node that manages the container running the service.

Let's read that again. Volumes are mapped at a cluster level; however, the physical storage of stateful data will exist on the node that manages the container running the service.

As such, users may wish to leverage placement constraints to ensure stateful services are ran on specific nodes. See the next section for more details on that.

Placement constraints

As a deeper level of configuration on the Docker orchestration layer, you can specify a placement constraint for a service, meaning, a service will only run on nodes matching a certain set of criteria.

To get a better understanding of the types of conditions that can be used, you can read more about how to use placement constraints on the official Docker documentation.

  1. Click the "ADD CONSTRAINT" button.
  2. Add the placement constraint in the field.
  3. If you'd like to add another placement constraint, you can click the "ADD CONSTRAINT" button again.

In this example, we are using the following placement constraint on a stateful service:

// Service configuration
placement-constraints: ["node.labels.stateful_apps == true"]

We have also configured one of our nodes to have the the corresponding label, thus this stateful service will only run on nodes with the label:

// Node configuration
labels: ["stateful_apps=true"]

You can read more about labeling nodes in the support article on Nodes.

As the final step, simply click the "CREATE" button at the end of the New service form to create the service. Containers will begin spinning up on the available infrastructure.

Update

As your software development team updates service images and makes them available in a container registry, you may need update the service configuration in MedStack.

There are two methods to access the service update screen:

Method 1

  1. Navigate to the cluster's Services tab.
  2. Click the name of the service you'd like to update.

Method 2

  1. Navigate to the cluster's Services tab.
  2. Click the "Options" selector button for the service you'd like to update.
  3. Select the option to "Show" the service.

Manually updating a service

Once you have landed on the service's page, you can click the button to  "UPDATE" the service, which will open the service configuration form.

The parameters you can update are explained in the creating a custom service section of this article.

After updating the service, you can save the change by clicking the "UPDATE" button at the bottom of the form.

Programatically updating a service

Webhooks

Depending on how you've configured your service, you can use webhooks to update a service. To learn more about this, check out our article on managing a service using webhooks.

API

We are currently developing an API that will allow you to have more granular control over updating services.

Delete

There are two methods to delete a custom service from your cluster: Method 1

  1. Navigate to the cluster's Services tab.
  2. Click the name of the managed service you'd like to update

Method 2

  1. Navigate to the cluster's Services tab.
  2. Click the "Options" selector button for the service you'd like to delete.
  3. Select the option to "Show"
  4. Click the button to "DELETE" the service.

Stop or pause a service

Sometimes it's desirable to destroy/stop all containers without deleting the service configuration in Docker. This can be done by setting the service replicas to 0. In order to start containers again, increase the replicas to greater than 0.

  1. Navigate to the cluster running the service of interest.
  2. Click the service's name to open the service details page that's being run in the container.
  3. Click the "Update" button to modify the service configuration.
  4. Change the "Replicas" count to zero.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Submit a request for support Submit a request for support