Skip to content

Commit aecba3f

Browse files
committed
feat: add helm chart and docker compose for hybrid executors
1 parent 29b2263 commit aecba3f

13 files changed

Lines changed: 1236 additions & 45 deletions

File tree

docs/cloud/features/scheduler/scheduler.md

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,40 @@ This gives you complete control over data security and network access while stil
165165

166166
Self-hosted executors as the name indicates are self-hosted workers that take on the responsibility of "executing" changes to the data warehouse. While Tobiko Cloud schedules and plans changes, the executors are responsible for executing those changes. Executors are docker containers that are configured to connect to Tobiko Cloud as well as your data warehouse. Connected to both, the executor pulls work from the cloud, whether it's a plan or scheduled background work from a run, and execute it on your data warehouse.
167167

168+
### Deployment Options
169+
170+
You can deploy the executor containers using any method that works for your infrastructure and operational requirements. The executors are standard Docker containers that can be deployed in any container environment as long as they're properly configured with the required environment variables.
171+
172+
For your convenience, we provide two reference implementations:
173+
174+
1. **Kubernetes with Helm Chart**: For production environments, we provide a [Helm chart](./scheduler/hybrid-executors/README.md) that includes robust configurability, secret management, and scaling options.
175+
176+
2. **Docker Compose**: For simpler environments or testing, we offer a [Docker Compose setup](./scheduler/hybrid-executors-docker-compose.md) to quickly deploy executors on any machine with Docker.
177+
178+
You're free to adapt these reference implementations or create your own deployment method that fits your specific needs. The only requirement is that two executor instances must be running (one for run operations and one for apply operations) and properly configured.
179+
168180
### Configuration
169181

170-
Exact configuration is left to the user and will vary based on the infrastructure and setup of the user, for example the executors could be run on a Kubernetes cluster or as a standalone pair of Docker containers depending on the user's infrastructure. The following details are an example of how this is done for a Postgres data warehouse and a pair of local containers running in docker.
182+
The following covers basic configuration concepts for hybrid executors. For detailed configuration options, please refer to the specific documentation for your chosen deployment method above.
183+
184+
Tobiko Cloud requires 2 executor instances to be running:
171185

172-
Tobiko Cloud requires 2 docker instances to be running, one to pick up runs and one for plan applications. The entrypoint for both is `executor run` and `executor apply` respectively. The executor container can be found on [Docker Hub](https://hub.docker.com/r/tobikodata/tcloud). In addition to running the container, the user will need to configure the executor with environment variables that point to Tobiko Cloud as well as the data warehouse.
186+
1. **Run Executor**: Handles scheduled model execution
187+
2. **Apply Executor**: Handles applying changes to the data warehouse
173188

174-
To connect to the Tobiko Cloud, the user will need to provide the following environment variables, replaced with the user's own values.
189+
Both executors need to be properly configured with environment variables to connect to Tobiko Cloud and your data warehouse.
190+
191+
#### Basic Environment Variables
192+
193+
To connect to Tobiko Cloud, you'll need to provide:
175194

176195
```env
177196
TCLOUD_URL=https://cloud.tobikodata.com/sqlmesh/acme/analytics_project
178-
TCLOUD_TOKEN=your_token
197+
TCLOUD_CLIENT_ID=your_client_id
198+
TCLOUD_CLIENT_SECRET=your_client_secret
179199
```
180200

181-
In addition to the above variables, a gateway is needed to provide a connection to a data warehouse. The following details are an example of how this is done for a Postgres data warehouse where the gateway is named `GATEWAY_A`. For more details on how to configure a gateway, see the details on other [engines](../../../integrations/overview.md#execution-engines) and how to [overide variables](../../../guides/configuration.md#overrides) as done below.
201+
To connect to your data warehouse, configure a gateway:
182202

183203
```env
184204
SQLMESH__DEFAULT_GATEWAY=GATEWAY_A
@@ -190,7 +210,7 @@ SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__USER=example_user
190210
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PASSWORD=example_password
191211
```
192212

193-
**Note**: If there are multiple gateways, each gateway will need to have its own set of environment variables. For example, if there are two gateways, `GATEWAY_A` and `GATEWAY_B`, the environment variables will need to be set for both gateways.
213+
**Note**: For multiple gateways, each gateway needs its own set of environment variables:
194214

195215
```env
196216
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__TYPE=<connection type>
@@ -199,14 +219,9 @@ SQLMESH__GATEWAYS__GATEWAY_B__CONNECTION__TYPE=<connection type>
199219
# <Gateway B connection settings>
200220
```
201221

202-
Once you have set up both sets of environment variables in a file named `local.env`, you can run the following command to start the executor:
203-
204-
```shell
205-
docker run -d --env-file local.env tobikodata/tcloud:latest -- executor run
206-
docker run -d --env-file local.env tobikodata/tcloud:latest -- executor apply
207-
```
222+
For more details, including secure secret management options, refer to the [Helm chart](./scheduler/hybrid-executors/README.md) or [Docker Compose](./scheduler/hybrid-executors-docker-compose.md) documentation.
208223

209-
After the executors are properly configured, they will appear in the cloud UI where they can be used to apply plans and execute scheduled runs.
224+
After the executors are properly configured and running, they will appear in the cloud UI where they can be used to apply plans and execute scheduled runs.
210225

211226
![executors](../scheduler/executors.png)
212227

@@ -224,43 +239,18 @@ While the exact requirements for executors vary depending on the customer's spec
224239

225240
Environment variables may also be passed to SQLMesh by mounting a `.env` file into the docker image and specifying it's full path with the environment variable `TCLOUD_ENV_FILE`.
226241

227-
**Note** These variables are only read at SQLMesh run time so variables that are used by `tcloud` such as `TCLOUD_URL`, `TCLOUD_TOKEN`, etc. must be passed as variables.
242+
**Note** These variables are only read at SQLMesh run time so variables that are used by `tcloud` such as `TCLOUD_URL`, `TCLOUD_CLIENT_ID`, `TCLOUD_CLIENT_SECRET`, etc. must be passed as variables.
228243

229244
### Health checks
230245

231-
In production settings, we recommend setting up health checks as well, as these can be helpful in understanding the health of executors. When calling via the entrypoint, the health checks are as follows:
246+
In production settings, we recommend setting up health checks to monitor the status of your executors. Health checks help ensure your executors are operating correctly and can identify issues before they impact your workflows.
232247

233-
```shell
234-
docker run -d --env-file local.env tobikodata/tcloud:latest -- executor run --check
235-
docker run -d --env-file local.env tobikodata/tcloud:latest -- executor apply --check
236-
```
248+
For detailed information on implementing health checks:
237249

238-
For environments that ignore the container's entrypoint, for example in the case of Kubernetes healthchecks, the health check is invoked as follows:
239-
240-
```yaml
241-
# For the run executor
242-
readinessProbe:
243-
exec:
244-
command:
245-
- "/app/pex"
246-
- "executor"
247-
- "run"
248-
- "--check"
249-
timeoutSeconds: 5
250-
```
250+
- **Kubernetes/Helm**: See the [Hybrid Executors Helm Chart documentation](./scheduler/hybrid-executors/README.md#verifying-the-installation) for information on health check configuration in Kubernetes.
251251

252-
```yaml
253-
# For the apply executor
254-
readinessProbe:
255-
exec:
256-
command:
257-
- "/app/pex"
258-
- "executor"
259-
- "apply"
260-
- "--check"
261-
timeoutSeconds: 5
262-
```
252+
- **Docker Compose**: Refer to the [Docker Compose setup documentation](./scheduler/hybrid-executors-docker-compose.md#health-checking) for health check implementation with Docker Compose.
263253

264-
Each executor type (run or apply) should have its own health check implemented to ensure proper monitoring of both components.
254+
Both executor types (run and apply) should have appropriate health checks implemented to ensure proper monitoring and reliability.
265255

266-
**Note** Please note the specified timeout. Depending on the allocated resources, sometimes the default timeout is too aggressive.
256+
**Note** When configuring health checks, ensure timeouts are set appropriately based on your resources. Default timeouts can sometimes be too aggressive depending on the allocated resources.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Tobiko Cloud Configuration
2+
ORGANIZATION=your-organization
3+
PROJECT=your-project
4+
TCLOUD_CLIENT_ID=your-client-id
5+
TCLOUD_CLIENT_SECRET=your-client-secret
6+
7+
# Database Configuration
8+
DEFAULT_GATEWAY=GATEWAY_A
9+
DB_TYPE=postgres
10+
DB_HOST=your-database-host
11+
DB_PORT=5432
12+
DB_NAME=your-database-name
13+
DB_USER=your-database-user
14+
DB_PASSWORD=your-database-password
15+
16+
# Optional: Resource Limits
17+
APPLY_MEMORY_LIMIT=4g
18+
APPLY_CPU_LIMIT=2
19+
APPLY_MEMORY_REQUEST=2g
20+
APPLY_CPU_REQUEST=1
21+
PLAN_MEMORY_LIMIT=4g
22+
PLAN_CPU_LIMIT=2
23+
PLAN_MEMORY_REQUEST=2g
24+
PLAN_CPU_REQUEST=1
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
version: '3.8'
2+
3+
services:
4+
apply-executor:
5+
image: tobikodata/tcloud:latest
6+
command: executor apply
7+
restart: unless-stopped
8+
environment:
9+
# Tobiko Cloud connection
10+
TCLOUD_URL: https://cloud.tobikodata.com/sqlmesh/${ORGANIZATION}/${PROJECT}
11+
TCLOUD_CLIENT_ID: ${TCLOUD_CLIENT_ID}
12+
TCLOUD_CLIENT_SECRET: ${TCLOUD_CLIENT_SECRET}
13+
14+
# SQLMesh configuration
15+
SQLMESH__DEFAULT_GATEWAY: ${DEFAULT_GATEWAY:-GATEWAY_A}
16+
17+
# Example database configuration for Postgres (adjust for your database)
18+
# All database parameters below should be customized for your specific setup
19+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__TYPE: ${DB_TYPE:-postgres}
20+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__HOST: ${DB_HOST}
21+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PORT: ${DB_PORT:-5432}
22+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__DATABASE: ${DB_NAME}
23+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__USER: ${DB_USER}
24+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PASSWORD: ${DB_PASSWORD}
25+
volumes:
26+
# Optional volume for persistent storage if needed
27+
- apply-executor-data:/app/data
28+
deploy:
29+
resources:
30+
limits:
31+
memory: ${APPLY_MEMORY_LIMIT:-4g}
32+
cpus: ${APPLY_CPU_LIMIT:-2}
33+
reservations:
34+
memory: ${APPLY_MEMORY_REQUEST:-2g}
35+
cpus: ${APPLY_CPU_REQUEST:-1}
36+
37+
run-executor:
38+
image: tobikodata/tcloud:latest
39+
command: executor run
40+
restart: unless-stopped
41+
environment:
42+
# Tobiko Cloud connection
43+
TCLOUD_URL: https://cloud.tobikodata.com/sqlmesh/${ORGANIZATION}/${PROJECT}
44+
TCLOUD_CLIENT_ID: ${TCLOUD_CLIENT_ID}
45+
TCLOUD_CLIENT_SECRET: ${TCLOUD_CLIENT_SECRET}
46+
47+
# SQLMesh configuration
48+
SQLMESH__DEFAULT_GATEWAY: ${DEFAULT_GATEWAY:-GATEWAY_A}
49+
50+
# Example database configuration for Postgres (adjust for your database)
51+
# All database parameters below should be customized for your specific setup
52+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__TYPE: ${DB_TYPE:-postgres}
53+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__HOST: ${DB_HOST}
54+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PORT: ${DB_PORT:-5432}
55+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__DATABASE: ${DB_NAME}
56+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__USER: ${DB_USER}
57+
SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PASSWORD: ${DB_PASSWORD}
58+
volumes:
59+
# Optional volume for persistent storage if needed
60+
- run-executor-data:/app/data
61+
deploy:
62+
resources:
63+
limits:
64+
memory: ${PLAN_MEMORY_LIMIT:-4g}
65+
cpus: ${PLAN_CPU_LIMIT:-2}
66+
reservations:
67+
memory: ${PLAN_MEMORY_REQUEST:-2g}
68+
cpus: ${PLAN_CPU_REQUEST:-1}
69+
70+
volumes:
71+
apply-executor-data: {}
72+
run-executor-data: {}

0 commit comments

Comments
 (0)