You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(consul-postgres-ha): rewrite "Adapting to your own workload" + retire design brief
README's adaptation guide now walks a worked example (add a fictional
billing:9090 service) end-to-end. ARCHITECTURE notes the allowlist is
platform-generated. design/declarative-services.md is deleted per the
hand-off section — the code + updated README are the surviving
artifacts; the index entry comes out too.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
entries, and `mesh-conn`'s peer-VIP allowlist from it. Adding a
129
+
microservice is one HCL block plus an image; no edits to `mesh-conn`,
130
+
the sidecar entrypoint, your app's source, or the CI workflow.
131
+
132
+
### Add a service: worked example
133
+
134
+
Say you want a billing service on port 9090 that the existing
135
+
`webdemo` calls into. End-to-end:
136
+
137
+
1.**Declare it in `cluster.tf`** — append one entry to
138
+
`local.services`:
139
+
140
+
```hcl
141
+
services_raw = [
142
+
{ name = "webdemo", port = 8080, subset = null },
143
+
{ name = "postgres-master", port = 5432, subset = "master" },
144
+
{ name = "postgres-replica", port = 5432, subset = "replica" },
145
+
{ name = "billing", port = 9090, subset = null }, # ← new
146
+
]
147
+
```
148
+
149
+
This is the only edit to the platform.
150
+
151
+
2.**Add the image** to `terraform.tfvars` (`billing_image = "..."`),
152
+
wire a `BILLING_IMAGE` variable + env entry on `phala_app.worker`,
153
+
and add a `billing` service to `compose/worker.yaml` (modelled on
154
+
`webdemo` — it just binds `127.0.0.1:9090` and serves).
155
+
156
+
3.**`terraform apply`**. The provider's in-place env update pushes
157
+
the new `SERVICES_JSON` to every CVM:
158
+
159
+
-`mesh-conn`'s allowlist extends to `{21000, 21001, 21002,
160
+
8300, 8301}` automatically — `MESH_CONN_ALLOWLIST` is computed
161
+
from `SERVICES_JSON` in `mesh-sidecar/entrypoint.sh`.
162
+
- Workers provision `127.10.0.13/32 dev lo`, append
163
+
`127.10.0.13 billing` to `/etc/hosts`, and start a third Envoy
164
+
supervise loop with `--base-id 3 -admin-bind 127.0.0.1:19002`.
165
+
- Coordinator-0 writes a default-allow intention for `billing`
166
+
and any subset/redirect resolvers implied by the declaration.
167
+
168
+
4.**From any container on any peer**, `curl http://billing:9090/...`
169
+
load-balances across all peers' `billing` instances over Connect
170
+
mTLS. No application-side service-discovery code.
171
+
172
+
### What the convention does for you
173
+
174
+
| Field on each entry | What it controls |
175
+
|---|---|
176
+
|`name`| Consul service name + `/etc/hosts` alias. Apps dial `${name}:${port}`. |
177
+
|`port`| Canonical app port. App binds `127.0.0.1:port`. Two entries sharing a port collapse onto one **backend** (one Envoy supervise loop, one `sidecar_port`, one Connect-mTLS endpoint) — that's how `postgres-master` and `postgres-replica` ride the same Patroni instance. |
178
+
|`subset`| Optional Consul service-subset filter (matches `Service.Tags`). Each subset-bearing entry generates a redirect resolver to the parent backend. Patroni's role-watcher (in `patroni/entrypoint.sh`) updates those tags on role flips. |
179
+
180
+
VIP octets and `sidecar_port` numbers are computed in HCL from
181
+
declaration order — first service gets `vip=10 sidecar_port=21000`,
182
+
second `vip=11 sidecar_port=21001`, and so on. Plan-time validation
183
+
catches duplicate `(name, subset)` tuples.
184
+
185
+
### Workload-specific pieces remaining
186
+
187
+
Only two files contain workload-specific logic after this refactor:
127
188
128
-
|Patroni-specific | Lives in |
189
+
|Workload-specific | Lives in |
129
190
|---|---|
130
-
| The Patroni image itself |`patroni/`|
131
-
| Patroni env block + REST/Postgres port choices|`compose/worker.yaml`|
132
-
| Postgres service VIPs + Connect upstreams |`cluster-example/cluster.tf` (`local.service_vips`) |
Copy file name to clipboardExpand all lines: consul-postgres-ha/design/README.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,6 @@ in their face.
12
12
13
13
| Doc | What |
14
14
|---|---|
15
-
|[`declarative-services.md`](declarative-services.md)| Adding a microservice should be one HCL block in `cluster.tf`. Today's `mesh-conn` allowlist is hardcoded Go; sidecar registration lives in app binaries; Envoy supervise loops are copy-pasted. This pass makes the service list declarative and generates the rest. |
16
15
|[`attestation-admission.md`](attestation-admission.md)| Use dstack TEE attestation as the mesh-conn admission credential, replacing/augmenting the shared TURN HMAC. Phased plan: per-app-id first, Consul-KV-rooted policy later. |
0 commit comments