Skip to content

Commit 4903d29

Browse files
committed
fix(platform): make groups core service
1 parent aae11f0 commit 4903d29

5 files changed

Lines changed: 31 additions & 65 deletions

File tree

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,17 @@ Default domain and port: `agyn.dev` on `2496`.
6868
- OpenFGA API: https://openfga.agyn.dev:2496/
6969
- OpenFGA Playground: https://openfga-playground.agyn.dev:2496/
7070

71-
## Optional NATS JetStream event bus
71+
## NATS JetStream event bus
7272

73-
The platform stack can deploy NATS JetStream for durable service-to-service
74-
events used by private Networks and the Groups service. Groups is wired into
75-
the platform stack and depends on NATS, so enable both when applying the
76-
platform stack:
73+
The platform stack deploys NATS JetStream for durable service-to-service
74+
events used by private Networks and the Groups service. Groups is wired as a
75+
core platform service and depends on NATS so it is created after the event bus.
7776

78-
```sh
79-
terraform -chdir=stacks/platform apply -var='groups_enabled=true' -var='nats_enabled=true'
80-
```
81-
82-
The local deployment creates the `nats` Argo CD application in the platform
83-
namespace, enables JetStream file storage with a PVC, configures the
84-
`AGYN_GROUPS` and `AGYN_NETWORKS` streams, and deploys the `groups-db` and
85-
`groups` Argo CD applications when `groups_enabled=true`. The stable in-cluster
86-
endpoint is available from the platform stack output `nats_endpoint`.
77+
The local deployment creates the `nats`, `groups-db`, and `groups` Argo CD
78+
applications in the platform namespace, enables JetStream file storage with a
79+
PVC, and configures the `AGYN_GROUPS` and `AGYN_NETWORKS` streams. The stable
80+
in-cluster endpoint is available from the platform stack output
81+
`nats_endpoint`.
8782

8883
## DEV/E2E-only diagnostics credentials
8984

stacks/platform/README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,10 @@ Platform charts are pulled from the GHCR OCI registry (`ghcr.io/agynio/charts`).
3838

3939
### NATS JetStream event bus
4040

41-
NATS JetStream is required by the Groups service and disabled by default so
42-
existing local stacks keep their previous footprint. Enable it together with
43-
Groups using platform stack variables:
44-
45-
```bash
46-
terraform -chdir=stacks/platform apply -var='groups_enabled=true' -var='nats_enabled=true'
47-
```
48-
49-
When enabled, Terraform creates an Argo CD application named `nats` in the
50-
platform namespace using the upstream NATS Helm chart. The application enables
41+
NATS JetStream is required by the Groups service and is deployed as a core
42+
platform application. Terraform creates an Argo CD application named `nats` in
43+
the platform namespace using the upstream NATS Helm chart. The application
44+
enables
5145
JetStream file storage with a PVC (`nats_jetstream_file_store_pvc_size`,
5246
default `10Gi`) and a matching file store max size
5347
(`nats_jetstream_file_store_max_size`, default `10Gi`). The stable in-cluster
@@ -70,10 +64,10 @@ stream config changes delete and recreate the Job instead of attempting an
7064
immutable Job update. Stream retention knobs follow the NATS API schema: age and
7165
duplicate window values are in nanoseconds, and size values are in bytes.
7266

73-
The Groups service is disabled by default for backwards compatibility. Set
74-
`groups_enabled=true` to deploy the `groups-db` and `groups` Argo CD
75-
applications. Terraform enforces `nats_enabled=true` for the Groups application
76-
because the chart is configured to use the in-cluster NATS endpoint above.
67+
The Groups service is deployed as a core platform application together with its
68+
`groups-db` PostgreSQL application. The Groups application depends on `nats`,
69+
`groups-db`, `authorization`, and `identity` so it is created after the event
70+
bus and required platform services.
7771

7872
### Graph persistence
7973

@@ -93,7 +87,8 @@ Verify persistence by:
9387
|-----------|--------------------|-------------------------------------|-------|
9488
| 5 | `platform-db` | PostgreSQL for platform workloads | Uses chart `oci://ghcr.io/agynio/charts/postgres-helm` with inline Helm values |
9589
| 18 | `k8s-runner` | Kubernetes workspace runner | Uses cluster-wide RBAC; TCP-only runner mode |
96-
| 18 | `groups` | Groups service | Optional; set `groups_enabled=true`; depends on `groups-db`, `authorization`, `identity`, and `nats` |
90+
| 16 | `nats` | NATS JetStream event bus | Required by Groups and private Networks |
91+
| 18 | `groups` | Groups service | Depends on `groups-db`, `authorization`, `identity`, and `nats` |
9792
| 20 | `platform-server` | Core platform API | Depends on `platform-db` |
9893
| 25 | `platform-ui` | Platform web UI | Connects to `platform-server` |
9994

stacks/platform/main.tf

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,17 +1664,6 @@ resource "random_password" "cluster_admin_token" {
16641664
special = false
16651665
}
16661666

1667-
resource "terraform_data" "groups_requires_nats" {
1668-
count = var.groups_enabled ? 1 : 0
1669-
1670-
lifecycle {
1671-
precondition {
1672-
condition = var.nats_enabled
1673-
error_message = "Groups requires NATS JetStream. Set nats_enabled=true when groups_enabled=true."
1674-
}
1675-
}
1676-
}
1677-
16781667
resource "openfga_relationship_tuple" "cluster_admin" {
16791668
store_id = module.openfga_authorization.store_id
16801669
authorization_model_id = module.openfga_authorization.model_id
@@ -3035,8 +3024,6 @@ resource "argocd_application" "organizations_db" {
30353024
}
30363025

30373026
resource "argocd_application" "groups_db" {
3038-
count = var.groups_enabled ? 1 : 0
3039-
30403027
depends_on = [argocd_repository.ghcr]
30413028
wait = true
30423029

@@ -3704,8 +3691,6 @@ resource "argocd_application" "notifications_redis" {
37043691
}
37053692

37063693
resource "argocd_application" "nats" {
3707-
count = var.nats_enabled ? 1 : 0
3708-
37093694
depends_on = [argocd_repository.nats_repo]
37103695
wait = true
37113696

@@ -4194,13 +4179,10 @@ resource "argocd_application" "organizations" {
41944179
}
41954180

41964181
resource "argocd_application" "groups" {
4197-
count = var.groups_enabled ? 1 : 0
4198-
41994182
depends_on = [
4200-
terraform_data.groups_requires_nats[0],
42014183
argocd_repository.ghcr,
4202-
argocd_application.nats[0],
4203-
argocd_application.groups_db[0],
4184+
argocd_application.nats,
4185+
argocd_application.groups_db,
42044186
argocd_application.authorization,
42054187
argocd_application.identity,
42064188
]

stacks/platform/outputs.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
output "platform_app_names" {
22
description = "Names of Argo CD applications managed by this stack"
3-
value = concat([
3+
value = [
44
argocd_application.platform_db.metadata[0].name,
55
argocd_application.threads_db.metadata[0].name,
66
argocd_application.metering_db.metadata[0].name,
@@ -46,12 +46,15 @@ output "platform_app_names" {
4646
argocd_application.tracing_app.metadata[0].name,
4747
argocd_application.gateway.metadata[0].name,
4848
argocd_application.llm_proxy.metadata[0].name,
49-
], argocd_application.groups_db[*].metadata[0].name, argocd_application.groups[*].metadata[0].name, argocd_application.nats[*].metadata[0].name)
49+
argocd_application.groups_db.metadata[0].name,
50+
argocd_application.nats.metadata[0].name,
51+
argocd_application.groups.metadata[0].name,
52+
]
5053
}
5154

5255
output "platform_app_ids" {
5356
description = "Identifiers returned by the Argo CD provider for the applications"
54-
value = concat([
57+
value = [
5558
argocd_application.platform_db.id,
5659
argocd_application.threads_db.id,
5760
argocd_application.metering_db.id,
@@ -97,7 +100,10 @@ output "platform_app_ids" {
97100
argocd_application.tracing_app.id,
98101
argocd_application.gateway.id,
99102
argocd_application.llm_proxy.id,
100-
], argocd_application.groups_db[*].id, argocd_application.groups[*].id, argocd_application.nats[*].id)
103+
argocd_application.groups_db.id,
104+
argocd_application.nats.id,
105+
argocd_application.groups.id,
106+
]
101107
}
102108

103109
output "platform_namespace" {

stacks/platform/variables.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ variable "groups_chart_version" {
113113
default = "0.1.0"
114114
}
115115

116-
variable "groups_enabled" {
117-
type = bool
118-
description = "Enable the Groups service and its PostgreSQL database"
119-
default = false
120-
}
121-
122116
variable "identity_chart_version" {
123117
type = string
124118
description = "Version of the identity Helm chart published to GHCR"
@@ -330,12 +324,6 @@ variable "notifications_redis_addr" {
330324
default = "notifications-redis-master.platform.svc.cluster.local:6379"
331325
}
332326

333-
variable "nats_enabled" {
334-
type = bool
335-
description = "Enable NATS JetStream deployment for durable platform events"
336-
default = false
337-
}
338-
339327
variable "nats_jetstream_file_store_pvc_size" {
340328
type = string
341329
description = "Persistent volume claim size for the NATS JetStream file store"

0 commit comments

Comments
 (0)