Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/mantis-cluster-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: mantis-cluster CI

on:
pull_request:
paths:
- 'packages/cluster/**'
- 'projects/biomemetics/labs/mantis/cluster/**'
- '.github/workflows/mantis-cluster-ci.yml'

jobs:
gbg-cluster:
name: '@gbg/cluster'
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/cluster
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
cache-dependency-path: packages/cluster/package-lock.json

- name: Install
run: npm install

- name: Typecheck
run: npm run typecheck

- name: Test
run: npm test

mantis-cluster:
name: '@mantis/cluster'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
cache-dependency-path: |
packages/cluster/package-lock.json
projects/biomemetics/labs/mantis/cluster/package-lock.json

- name: Install @gbg/cluster
working-directory: packages/cluster
run: npm install

- name: Install @mantis/cluster
working-directory: projects/biomemetics/labs/mantis/cluster
run: npm install

- name: Typecheck
working-directory: projects/biomemetics/labs/mantis/cluster
run: npm run typecheck

- name: Test
working-directory: projects/biomemetics/labs/mantis/cluster
run: npm test
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"workspaces": [
"packages/*",
"!packages/codemode-pi",
"!packages/pi-workflows"
"!packages/pi-workflows",
"!packages/cluster"
]
}
4 changes: 4 additions & 0 deletions packages/cluster/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
.alchemy/
dist/
*.log
1 change: 1 addition & 0 deletions packages/cluster/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy-peer-deps=true
70 changes: 70 additions & 0 deletions packages/cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# @gbg/cluster

Lab Alchemy host. k3d hosts applets on kube context `k3d-tmnl`. CRDs
(`LabImage`, `LabRegistry`, `LabWorkload`, `LabApplet`) use API group
`tmnl.gbg.dev/v1alpha1`. Those strings are names, not a claim that TMNL is
the cluster.

## Cluster

k3d is the local kube runtime. Context name: `k3d-tmnl`. Create it with:

```text
nix develop ./packages/tmnl#tmnl-k8s
k8s-cluster-create
```

`k8s-cluster-create` lives in `packages/tmnl/nix/modules/k8s.nix` as a helper
path. Cosmo/WunderGraph home is `@gbg/nexus`, not that path. Do not copy the
helper here. Alchemy resolves kubeconfig from `$KUBECONFIG` or
`~/.kube/config`. There is no host path in this stack.

## Stack

`alchemy.run.ts` is the composition root. Run commands from this directory
so `Alchemy.localState()` writes `.alchemy/` here.

- `Kubernetes.providers()` only
- `Alchemy.localState()`
- `Kubernetes.KubeConfig({ context: "k3d-tmnl" })`
- four CRDs via `Kubernetes.Manifest`

Labs consume this host; they do not add a second Alchemy composition root.

No `AWS.providers()`, no Cloudflare resources, no kind files, no EKS/GKE/AKS,
no paid Workers/DO/Queues, no ECR/GCR/ACR.

This package uses its own npm lock so Alchemy's `effect@4.0.0-rc.110` peer
does not hoist over the repo `effect@4.0.0-beta.93` pin.

## CRDs

| Kind | Plural | Role |
|------|--------|------|
| LabImage | labimages | Image coordinate + optional digest / registry ref |
| LabRegistry | labregistries | In-cluster OCI. Default image: `ghcr.io/project-zot/zot-linux-amd64` (Zot). `registry:2` is the other local/free option. Never ECR/GCR/ACR. |
| LabWorkload | labworkloads | Generic workload (CosmoRouter minus GraphQL) |
| LabApplet | labapplets | TanStack Start specialization of LabWorkload |

## Cosmo

Cosmo/WunderGraph home is `@gbg/nexus` (`packages/nexus`). Not tmnl. Not
plexus. tmnl consumes nexus. This package does not copy Cosmo Pepr/CRD
sources out of tmnl. Catalog stays Postgres off-cluster; there is no catalog
pod.

One NATS: Cosmo router EDFS and `@tmnl/msh` share the existing helm NATS at
`packages/tmnl/nix/modules/nats/values.yaml`. Do not stand up a second NATS.

This package is types + CRD Manifests, not a second Pepr module and not a
reconcile controller.

## Hold deploy

Do not run `alchemy deploy` from this land.

```text
npm install
npm test
npm run typecheck
```
46 changes: 46 additions & 0 deletions packages/cluster/alchemy.run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as Alchemy from "alchemy";
import * as Kubernetes from "alchemy/Kubernetes";
import * as Effect from "effect/Effect";
import { cluster } from "./src/cluster";
import { LabAppletCRD } from "./src/crd/source/lab-applet.crd";
import { LabImageCRD } from "./src/crd/source/lab-image.crd";
import { LabRegistryCRD } from "./src/crd/source/lab-registry.crd";
import { LabWorkloadCRD } from "./src/crd/source/lab-workload.crd";

export { cluster };

export default Alchemy.Stack(
"LabCluster",
{
providers: Kubernetes.providers(),
state: Alchemy.localState(),
},
Effect.gen(function* () {
const labImage = yield* Kubernetes.Manifest("LabImageCRD", {
cluster,
manifest: LabImageCRD,
});
const labRegistry = yield* Kubernetes.Manifest("LabRegistryCRD", {
cluster,
manifest: LabRegistryCRD,
});
const labWorkload = yield* Kubernetes.Manifest("LabWorkloadCRD", {
cluster,
manifest: LabWorkloadCRD,
});
const labApplet = yield* Kubernetes.Manifest("LabAppletCRD", {
cluster,
manifest: LabAppletCRD,
});

return {
kubeContext: "k3d-tmnl",
crds: {
labImage: labImage.name,
labRegistry: labRegistry.name,
labWorkload: labWorkload.name,
labApplet: labApplet.name,
},
};
}),
);
Loading
Loading