Skip to content

Declare cluster services in Pulumi instead of YAML - #160

Open
limwa wants to merge 2 commits into
mainfrom
limwa/k8s-yaml-to-pulumi-refactor
Open

limwa wants to merge 2 commits into
mainfrom
limwa/k8s-yaml-to-pulumi-refactor

Conversation

@limwa

@limwa limwa commented Nov 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces the hand-written Kubernetes YAML under services/ with one Pulumi project, services/pulumi/niployments, with production and development stacks.
  • Organizes the program by layer: platform/ (cert-manager, Traefik, Cilium, Longhorn, Harbor, monitoring, and others), databases/ (MongoDB, CloudNativePG, Valkey, pgAdmin), apps/, and dev/. Reusable building blocks live in components/, and Helm values in assets/.
  • Types CRD resources through a @pulumi/crds SDK generated from committed manifests in services/pulumi/crd-manifests/. Generation runs through generate-crds-sdk.sh, and crds.yaml plus sync-crds.sh handle source updates.
  • Adds services/pulumi/README.md and niployments/MIGRATION.md covering setup, the stacks, and how to adopt the resources already running in the cluster.
  • Adds scripts/adopt-inventory.sh and utils/adopt.ts so live cluster objects are imported into state rather than recreated.
  • Updates CI: the Pulumi linter now runs oxfmt and oxlint, plus a new build-and-test job using Pulumi mocks. The prepare action generates the CRD SDK before installing dependencies.
  • Updates dev/setup-kind-cluster.sh so it only creates the kind cluster and Cilium. Everything else is deployed by pulumi up on the development stack.
  • Removes the old services/* YAML and the services/pulumi/niployments/services/ TypeScript modules that they replaced.

Testing

  • Ran the Pulumi mock tests (tests/development.test.ts, tests/production.test.ts) and tsc for the project.
  • Ran a real-engine check on a scratch kind cluster:
    • pulumi up on the development stack created 24 resources.
    • The next pulumi preview showed 24 unchanged.
    • Adoption imported 17 existing objects, created 7, and updated 9. The preview afterwards again showed 24 unchanged.
  • Did not run pulumi up against the production cluster. The first production run will adopt existing resources, so review pulumi preview --diff carefully before applying it.
  • Did not test the Pulumi-managed CRD SDK generation in CI. The workflow change is untested until it runs on a PR.

limwa added 2 commits November 2, 2026 21:42
- Replace the crd2pulumi/sync-crds pipeline with typed CRDs generated by the Pulumi Kubernetes provider (@pulumi/crds from committed crd-manifests/)
- Reorganize niployments into platform/, databases/, apps/, components/ and dev/ modules, gated by stack features
- Add a Pulumi mocks test job to CI and switch linting and formatting to oxlint and oxfmt
- Make dev/setup-kind-cluster.sh bootstrap only kind and Cilium; Pulumi deploys the rest
- Add node 24, pnpm, pulumi, yq, jq and kube-linter to the flake dev shell
- Move the Pulumi project into services/pulumi/niployments and drop the root pnpm workspace
- Declare the CRD SDK in Pulumi.yaml `packages:`; `pulumi install` generates it into sdks/crds
- Remove generate-crds-sdk.sh and the crds/ workspace package; sync-crds.sh regenerates the packages entry
- Run TypeScript directly via ts-node instead of a tsc build step; tests run from tests/*.test.ts
- Update the prepare-pulumi-project CI action to use pulumi install from niployments
@HenriqueSFernandes

Copy link
Copy Markdown
Member

I'm not going to read that but LGTM 🧑‍🦯

@HenriqueSFernandes HenriqueSFernandes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧑‍🦯🧑‍🦯🧑‍🦯🧑‍🦯🧑‍🦯🧑‍🦯🧑‍🦯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants