Search…
Adding and Removing Services
You may want more or less services based on templates or for particular environments
The services stanza in either the Default Environment Configuration or the Environment Specific Configuration define the services that will be deployed for your application, but sometimes you may want different ones per template or by environment. A good example of this is if you use RDS for staging and production, but Postgres for your ephemeral environments. There are two ways to do and this guide will walk you through both approaches.

Remove service from template

If the service 'postgres' is included in your default services and you want to remove it from your permanent template, you do this under the environment_templates section. You need to include remove: true . If you do not use the the remove directive, the parser will assume you just want to override parts of the service instead.
1
environment_templates:
2
- name: ephemeral
3
datasets:
4
- name: release-prod
5
- name: permanent
6
services:
7
- name: 'postgres'
8
remove: true
9
auto_deploy: false
10
hostnames:
11
- frontend: frontend-staging-${domain}
12
- docs: docs-staging-${domain}
13
- backend: backend-staging-${domain}
14
tracking_branch: maste
Copied!
Remove the Postgres service from all permanent environments

Add service in template

Another way to only include postgres in your ephemeral template is to not create it in your default services and only create the service in the ephemeral section of the template. The difference in syntax is you must include add: true. If you don't include the add directive the parser will assume you are trying to override something about an existing service and throw an error as the service name 'postgres' won't exist.
1
environment_templates:
2
- name: ephemeral
3
services:
4
- name: postgres
5
add: true
6
image: postgres:11.4-alpine
7
registry: public
8
volumes:
9
- type: persistent
10
name: postgres
11
mount_path: "/var/lib/postgresql/data"
12
ports:
13
- type: container_port
14
port: '5432'
15
storage:
16
size: 100Gi
17
datasets:
18
- name: release-prod
19
- name: permanent
20
auto_deploy: false
21
hostnames:
22
- frontend: frontend-staging-${domain}
23
- docs: docs-staging-${domain}
24
- backend: backend-staging-${domain}
25
tracking_branch: master
Copied!
Adding postgres service only for ephemeral environments based on this template
Besides these two methods, which are done in the Default Environment Config, you can also just manually delete the service from the services section of the Environment Specific Configuration. In this example, you would have the 'postgres' service in your default services section, but when you go create a permanent environment, before deploying it, you would just remove it from the configuration and save it. Then, when you deploy that configuration it would not include Postgres.
Last modified 9mo ago