Upsun User Documentation

Add services

Sign up

Get your free trial by clicking the link below.

Get your Upsun free trial

Upsun includes many services, so you don’t have to subscribe to external cache or search engine services. Because the services are included in your project, you can manage them through Git and they’re backed up together with the rest of your project.

Your project defines the services configuration from a top-level key called services, which is placed in a unified configuration file like .upsun/config.yaml.

If you don’t need any services (such as for a static website), you don’t need to include this configuration. Read on to see how to add services.

Add a service Anchor to this heading

Adding a service is a two-step process.

1. Configure the service Anchor to this heading

All service configuration happens in the .upsun/config.yaml file in your Git repository.

Configure your service in the following pattern:

.upsun/config.yaml
# The name of the service container. Must be unique within a project.
services:
    SERVICE_NAME:
        type: SERVICE_TYPE:VERSION
        # Other options...

An example service configuration for two databases might look like this:

.upsun/config.yaml
services:
    # The name of the service container. Must be unique within a project.
    mariadb:
        type: mariadb:11.2
    # The name of the service container. Must be unique within a project.
    postgresql:
        type: postgresql:16

This YAML file contains a dictionary defining all of the services you want to use. The top-level key services defines an object of all of the services to be provisioned for the project. Below that, come custom service names (SERVICE_NAME; in the example, mariadb and postgresql), which you use to identify the service in step 2.

You can give it any name you want with lowercase alphanumeric characters, hyphens, and underscores.

Service options Anchor to this heading

The following table presents the keys you can define for each service:

Name Type Required Description
type string Yes One of the available services in the format type:version.
configuration dictionary For some services Some services have additional specific configuration options that can be defined here, such as specific endpoints. See the given service page for more details.
relationships dictionary For some services Some services require a relationship to your app. The content of the dictionary has the same type as the relationships dictionary for app configuration. The endpoint_name for apps is always http.
Resources (CPU, RAM, disk) Anchor to this heading

Upsun allows you to configure resources (CPU, RAM, and disk) per environment for each of your services. For more information, see how to manage resources.

You configure the disk size in MB. Your actual available disk space is slightly smaller with some space used for formatting and the filesystem journal. When checking available space, note whether it’s reported in MB or MiB.

You can decrease the size of an existing disk for a service. If you do so, be aware that:

  • Backups from before the downsize are incompatible and can no longer be used. You need to create new backups.
  • The downsize fails if there’s more data on the disk than the desired size.

2. Connect the service Anchor to this heading

To connect the service, use the following configuration:

.upsun/config.yaml
applications:
    # The name of the app container. Must be unique within a project.
    APP_NAME:

        # Other options...

        # Relationships enable an app container's access to a service.
        # The example below shows simplified configuration leveraging a default service (identified from the relationship name) and a default endpoint.
        # See the Application reference for all options for defining relationships and endpoints.
        relationships:
            SERVICE_NAME:
services:
    # The name of the service container. Must be unique within a project.
    SERVICE_NAME:
        type: SERVICE_TYPE:VERSION
        # Other options...

You can define <SERVICE_NAME> as you like, so long as it’s unique between all defined services and matches in both the application and services configuration.

The example above leverages default endpoint configuration for relationships. That is, it uses default endpoints behind-the-scenes, providing a relationship (the network address a service is accessible from) that is identical to the name of that service.

Depending on your needs, instead of default endpoint configuration, you can use explicit endpoint configuration.

An example relationship to connect to the databases given in the example in step 1:

.upsun/config.yaml
applications:
    # The name of the app container. Must be unique within a project.
    APP_NAME:
        relationships:
            mariadb:
            postgresql:
services:
    mariadb:
        type: mariadb:11.2
    postgresql:
        type: postgresql:16

As with the service name, you can give the relationship any name you want with lowercase alphanumeric characters, hyphens, and underscores. It helps if the service name and relationship name are different, but it isn’t required.

Each service offers one or more endpoints for connections, depending on the service. An endpoint is a named set of credentials to give access to other apps and services in your project. If you don’t specify one in the service configuration, a default endpoint is created. The default endpoint varies by service, generally being its type (such as mysql or solr).

Available services Anchor to this heading

The following table presents the available service types and their versions. Add them to the type key of the service configuration in the format type:version.

Service type Supported versions
Headless Chrome chrome-headless 120, 113, 95, 91, 86, 84, 83, 81, 80, 73
Elasticsearch elasticsearch 8.5, 7.17
InfluxDB influxdb 2.7, 2.3
Kafka kafka 3.7, 3.6, 3.4, 3.2
MariaDB/MySQL mariadb 11.2, 11.0, 10.11, 10.6, 10.5, 10.4
Memcached memcached 1.6, 1.5, 1.4
MongoDB mongodb
MongoDB Premium mongodb-enterprise 7.0, 6.0, 5.0, 4.4, 4.2
MariaDB/MySQL mysql 11.0, 10.11, 10.6, 10.5, 10.4, 10.3
Network Storage network-storage 2.0
OpenSearch opensearch 2, 1
Oracle MySQL oracle-mysql 8.0, 5.7
PostgreSQL postgresql 16, 15, 14, 13, 12
RabbitMQ rabbitmq 3.13, 3.12
Redis redis 7.2, 7.0, 6.2
Solr solr 9.4, 9.2, 9.1, 8.11
Varnish varnish 7.3, 7.2, 6.0
Vault KMS vault-kms 1.12

Service versions Anchor to this heading

These services generally follow semantic versioning conventions. You can select the major version, but the latest compatible minor is applied automatically and can’t be overridden. Patch versions are applied periodically for bug fixes and the like. When you deploy your app, you always get the latest available patches.

Service timezones Anchor to this heading

All services have their system timezone set to UTC by default. For some services, you can change the timezone for the running service (this doesn’t affect the container itself and so logs are still in UTC).

Connect to a service Anchor to this heading

For security reasons, you can’t access services directly through HTTP. You can connect through your app or by opening an SSH tunnel to access the service directly.

Once a service is running and exposed via a relationship, its credentials (such as the host, username, and password) are automatically available as service environment variables, in the $<RELATIONSHIP-NAME>_<SERVICE-PROPERTY> format. The available information is documented on each service’s page, along with sample code for how to connect to it from your app.

The service environment variable names are fixed, but the values may change if you change the relationship name to the service. So use the environment variable rather than hard coding the values.

Connecting to a service using an SSH tunnel is a two-step process.

1. Obtain service credentials Anchor to this heading

To get the credentials for a given service, run the following command:

upsun relationships

You get output like the following:

mariadb:
    -
        username: user
        scheme: mysql
        service: mariadb
        fragment: null
        ip: 198.51.100.37
        hostname: abcdefghijklm1234567890123.mariadb.service._.eu.platformsh.site
        public: false
        cluster: abcdefgh1234567-main-abcd123
        host: mariadb.internal
        rel: mysql
        query:
            is_master: true
        path: main
        password: ''
        type: 'mariadb:10.6'
        port: 3306
        host_mapped: false
        url: 'mysql://user:@mariadb.internal:3306/main'

With this example, you can connect to the mariadb relationship with the user user, an empty password, and the database name main (from the path). The url property shows a full database connection that can be used from your app.

You can obtain the complete list of available service environment variables in your app container by running upsun ssh env.

Note that the information about the relationship can change when an app is redeployed or restarted or the relationship is changed. So your apps should only rely on the service environment variables directly rather than hard coding any values.

2. Open an SSH tunnel Anchor to this heading

Open a single SSH tunnel by running the following CLI command:

upsun tunnel:single --relationship RELATIONSHIP_NAME

By default, this opens a tunnel at 127.0.0.1:30000. You can specify the port for the connection using the --port flag.

You can then connect to this service in a separate terminal or locally running app. With the example above, you connect to a URL like the following: mysql://user:@127.0.0.1:30000/main

Upgrading services Anchor to this heading

Upsun provides a large number of managed service versions. As new versions are made available, you will inevitably upgrade infrastructure to a more recent (or latest version).

When you do so, we would recommend:

  1. Use preview environments. Leverage preview (non-production environments) to perform the upgrade, then merge the upgrade into production (promotion). This will give you an opportunity to test inherited production data in a safe, isolated environment first.
  2. Upgrade progressively. For one reason or another, you may be more than a single version behind the upgrade you are trying to perform. To avoid data loss issues caused by large differences in versions, upgrade one version at a time.

Is this page helpful?