Overview
This template provides a production‑ready CockroachDB instance as a Monk runnable. You can:- Run it directly to get a managed CockroachDB container with sensible defaults
- Inherit it in your own runnable to seamlessly add a distributed SQL database to your stack
What this template manages
- CockroachDB container (
cockroachimage, configurable tag) - Network service on port 26257 (SQL connections)
- Admin UI on port 8080
- Persistent volumes for data storage
Quick start (run directly)
- Load templates
- Run CockroachDB with defaults
- Customize configuration (recommended via inheritance)
variables. Secrets added with monk secrets add will not affect this runnable unless you inherit it and reference those secrets.
- Preferred: inherit and replace variables with
secret("...")as shown below. - Alternative: fork/clone and edit the
variablesincockroachdb.yml, thenmonk load MANIFESTand run.
localhost:26257 (or the runnable hostname inside Monk networks) using a PostgreSQL-compatible client. Access the admin UI at http://localhost:8080.
Configuration
Key variables you can customize in this template:${monk-volume-path}/cockroachdb:/cockroach/cockroach-data on the host.
Use by inheritance (recommended for apps)
Inherit the CockroachDB runnable in your application and declare a connection. Example:Ports and connectivity
- Service: CockroachDB SQL on TCP port
26257 - Admin UI: HTTP on TCP port
8080 - From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve the DB host.
Persistence and configuration
- Data path:
${monk-volume-path}/cockroachdb:/cockroach/cockroach-data - CockroachDB stores all database data in this directory
- Ensure the host volumes are writable by the container user
PostgreSQL compatibility
CockroachDB speaks the PostgreSQL wire protocol, so you can use existing PostgreSQL client drivers and libraries to connect. It supports most standard PostgreSQL SQL features.Related templates
- For CockroachDB cluster deployment, configure multiple nodes with
--joinflags. - Use
pgadmin/for web-based PostgreSQL-compatible administration. - Combine with
haproxy/for load balancing.
Troubleshooting
- CockroachDB may take a few moments to start.
- Ensure the host volumes are writable by the container user.
- Check logs:
- Access admin UI to monitor cluster health:
http://localhost:8080