platform
Pulumi stacks for CYC Community Sailing Center's shared Google Cloud platform: the things no single
app owns. The apps that run on it live in their own repos, such as
isthmia.
The docs site publishes docs/ from main: how the
platform is built, its data model, and the planning engine.
Stacks
| Stack |
Holds |
Applied by |
bootstrap |
Service accounts and project IAM, the Pulumi state buckets and KMS keys, the org's GitHub repos and settings, Firebase on the project, and Listmonk's public pictures bucket and its key |
A human with project Owner and gh admin:org. Never CI. |
infra |
The VPC, the cluster subnet and its Cloud NAT on a static address, the private services peering, the prod Cloud SQL instance, the DNS zones, Artifact Registry and its cleanup policy, the GKE Autopilot cluster, the shared Gateway, its address and certificates, the prod namespace with its quota and network policy, the prod Job alerts, the log exclusions, the public website's Firebase Hosting site, Amazon SES for the newsletter and mail.<external domain>'s certificate, and prod's platform/outputs.json |
deploy-runner, from Actions after approval. A deployer, with mise run deploy, when breaking glass. |
backend |
Directus, with the schema apply from schemas/, its roles, policies, and permission rules, the sync and website build machine users, its OIDC client, and MCP, and the clubspot-sync and gsuite-sync CronJobs |
deploy-runner, from Actions on a push to main, after infra. |
inbox |
FreeScout, the shared inbox at inbox.<domain>, from our own image: its database, disk, secrets, OIDC client, and A record |
deploy-runner, from Actions on a push to main, after backend. |
listmonk |
Listmonk, the newsletter at mail.<external domain>: its database, and the settings, roles, list and API logins it writes before each start. It sends through SES (docs/newsletter.md) |
deploy-runner, from Actions on a push to main, after inbox. |
authentik |
Authentik, the sign-in at login.<domain>: its server and worker, database, secrets, and A record, and its own configuration: flows, stages, policies, the Google source, the staff group and the shared inbox's sign-in group, the Admins superuser group, the Directus and Inbox OIDC and portal proxy applications, and Listmonk's OIDC application |
deploy-runner, from Actions on a push to main, after listmonk. |
@cyc-seattle/platform
src/ is the @cyc-seattle/platform package, which the stacks here and the apps' stacks import:
getPlatformOutputs() reads an environment's platform/outputs.json from its state bucket. The
infra stack writes it. It holds the environment's namespace and domain, the Gateway and its
address (gatewayAddress, for an app's own DNS records), and the Cloud SQL instance's connection
name and private IP (sqlHost). It lets an app's stack read the platform's values without a
StackReference to infra (cyc-seattle/isthmia#215).
clusterProvider(platform) builds a Kubernetes provider for the cluster. Its kubeconfig runs
gke-gcloud-auth-plugin with Application Default Credentials, so Pulumi must run under mise,
where mise run install puts the plugin on PATH.
Workload runs a long-lived process with no route: a Deployment, a ServiceAccount, and, when it
has ports, a ClusterIP Service that other pods in the namespace reach at host. With more than
one replica, spreadAcrossZones spreads them, and minAvailable adds a PodDisruptionBudget.
podAnnotations sets annotations such as cluster-autoscaler.kubernetes.io/safe-to-evict. A
pod with safe-to-evict: "false" gets at least 500m CPU and 512Mi from Autopilot, so ask for that
much, or every preview shows a change. progressDeadlineSeconds gives a slow rollout longer than
Kubernetes' 600 seconds before the deploy fails.
WebService is a Workload behind the environment's Gateway at hostname. Its Service exposes
port as port 80, and its readiness probe must be an HTTP GET, which the load balancer's health
check reuses unless healthCheck.path names a cheaper path. With paths, it claims only those path prefixes on hostname, and another
WebService can serve the rest of it. A stopping pod keeps serving for 10 seconds, while the load
balancer stops sending to it, then has 30 seconds to exit.
ScheduledJob runs a CronJob on schedule, in America/Los_Angeles unless timeZone says
otherwise. A run never overlaps the one before it, gets an hour, and doesn't retry, by default.
- All three run non-root with a read-only root filesystem, no capabilities, and no service account
token. Their limits equal their requests, unless
limits raises one,
such as CPU to burst. Their pods get no IAM; grant roles to member, a Workload Identity
principal, or set serviceAccountAnnotations to run as a Google service account.
enableService enables a Google Cloud API.
mise run build builds it into dist/, which is all it publishes. .github/workflows/release.yml
releases each merge to main with semantic-release, versioned by the conventional commits, before
it deploys.
Environments
Every app runs on the one GKE Autopilot cluster, in its environment's namespace, on regular
capacity. isthmia's portal and platform's authentik and backend (Directus and the two syncs as
CronJobs) run in prod. There's no other deployed environment: the integration tests run on a
throwaway stack in each CI job (docs/testing.md, #171).
| Stack |
Namespace |
Domain |
Deploy identity |
prod |
prod |
cycsail.team |
deploy-runner |
Each namespace denies ingress from other namespaces except the load balancer's. Each app writes its
own A records, pointing at gatewayAddress.
A Job that fails in prod, or a CronJob there with no successful Job in 3 hours, raises an alert.
It emails each address in infra:alertEmails, a secret in the stack's config, which holds the
maintainer's address (#20).
Setup
mise provides the tools.
mise trust
mise run install
Pulumi uses Application Default Credentials for GCP and for the state bucket. Log them in as your own
account with mise run auth-adc in the workplace, which
links this checkout's .gcloud/ to its one login. docs/manual-setup.md lists the access a
deployer needs first.
Deploy
From Actions
A PR runs ci from .github/workflows/pull-request.yml, and every integration test from .github/workflows/integration-ci.yml. .github/workflows/release.yml releases and deploys through the org's reusable deploy.yml, which
authenticates with Workload Identity Federation and stores no credentials. Each job runs in a
GitHub environment that holds its identity and state bucket:
| Event |
Jobs, in order |
| Pull request |
ci and integration |
Push to main |
release, then prod-preview, then prod, which waits for the maintainers approval |
Run by hand, from main |
The same as a push to main |
A PR merges only once integration passes, so each push to main goes straight to prod (#171).
prod-preview runs mise run preview as deploy-runner and writes the diff to the job summary.
prod runs mise run deploy on the same commit once approved. It runs only when the preview shows
changes, so a merge that changes nothing in prod asks for no approval. prod builds an image only
when its tag isn't in the registry yet. The next preview then shows the image's resource dropped,
which keeps the tag in the registry, so the next merge asks for approval even if it changes nothing
else.
PULUMI_STACK picks what the tasks run (scripts/each-stack): prod is infra, backend, inbox,
listmonk, then authentik.
bootstrap is never deployed from Actions (cyc-seattle/isthmia#118). It holds the identities that
CI assumes, and a human with project Owner and gh admin:org applies it with the tasks below.
From a laptop
Local deploys stay as the break-glass path. A deployer applies with the same tasks:
mise run preview-bootstrap
mise run deploy-bootstrap
mise run preview
mise run deploy
mise run deploy applies infra, backend, inbox, listmonk, then authentik. isthmia's prod stacks read its outputs through a StackReference.
infra also writes prod's platform values to platform/outputs.json in prod's state bucket, which
getPlatformOutputs() reads.
bootstrap's GitHub provider uses gh auth token, so log gh in as a cyc-seattle org owner with
the admin:org scope: gh auth refresh -h github.com -s admin:org. Deploys refresh first, so they
delete a label added by hand.
State
Each environment's state lives in its own bucket, gs://cyc-admin-scripts-pulumi-<stack>, with its
secrets encrypted by the state-<stack> KMS key. stacks/bootstrap/state.ts creates both.
mise.toml picks the bucket from PULUMI_STACK, which defaults to prod, so stack names are
organization/<project>/<stack>. It sets GOOGLE_APPLICATION_CREDENTIALS to the shared .gcloud/
login only when it isn't already set, so Actions' credentials win.
bootstrap's own state lives in the bucket it creates. Both the bucket and the key are protected.
Development
mise run ci
Runs the type check, Prettier, ESLint, the unit tests, and the docs site's build. Tests mock Pulumi with
pulumi.runtime.setMocks and never call a live API.
mise run docs-dev
Serves the docs site, from docs-site/, as you edit docs/. A page in docs/ takes its title from
its first heading, and a link to another file in the repo goes to GitHub. The build fails on a broken
link. .github/workflows/docs.yml publishes it to GitHub Pages on every push to main.
mise run ci-stack
mise run integration-ci
mise run ci-stack-down
Runs the Gherkin scenarios in features/ against a throwaway stack in Docker, as CI does. It needs
the Directus license key in DIRECTUS_LICENSE_KEY. docs/testing.md has the rest.