Skip to content

refactor(manifests): extract shared patches into Kustomize Components#933

Merged
mergify[bot] merged 1 commit intomainfrom
kdreyer/refactor-kustomize
Mar 18, 2026
Merged

refactor(manifests): extract shared patches into Kustomize Components#933
mergify[bot] merged 1 commit intomainfrom
kdreyer/refactor-kustomize

Conversation

@ktdreyer
Copy link
Contributor

Summary

  • Split base/ into core/, rbac/, and platform/ sub-kustomizations so future overlays can selectively include only what they need
  • Extract 10 duplicated patch files across 4 overlays into 4 reusable Kustomize Components: oauth-proxy, postgresql-rhel, ambient-api-server-db, postgresql-init-scripts
  • Update production, local-dev, e2e, and kind overlays to reference components instead of maintaining their own copies of identical patches

Adding a new OpenShift overlay (like mpp-preprod) currently requires copying patch files from an existing overlay and hoping nothing was missed. With components, a new overlay composes the mixins it needs — no copy-paste required.

All 5 overlays produce identical oc kustomize output before and after this change.

Fixes #836

Test plan

  • oc kustomize output diffed against pre-refactoring baselines for all 5 overlays (production, e2e, kind, kind-local, local-dev) — all identical
  • CI overlay builds pass

@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

Walkthrough

Restructures Kustomize manifests into reusable components and a platform/core split: adds component kustomizations (oauth-proxy, postgresql-rhel, postgresql-init-scripts, ambient-api-server-db), introduces base/core and base/platform kustomizations, updates base and overlays to reference components, and removes many overlay-specific patches and inline resources.

Changes

Cohort / File(s) Summary
New Core Base
components/manifests/base/core/kustomization.yaml
Adds a core base kustomization listing core resources and two ConfigMapGenerators (ambient-models, ambient-flags) with name suffix hashes disabled.
Base -> Platform Split
components/manifests/base/kustomization.yaml, components/manifests/base/platform/kustomization.yaml
Refactors base to reference a platform placeholder; removes inline ambient models/flags ConfigMapGenerators from base and adds an Images block; adds new platform kustomization that enumerates namespace, crds, and secrets/db resources.
New Kustomize Components
components/manifests/components/oauth-proxy/kustomization.yaml, components/manifests/components/postgresql-rhel/kustomization.yaml, components/manifests/components/postgresql-init-scripts/kustomization.yaml, components/manifests/components/ambient-api-server-db/kustomization.yaml
Introduces four Component manifests that encapsulate previously duplicated patches and resource additions (oauth proxy frontend patches, RHEL PostgreSQL patches, PostgreSQL init-scripts resource/patch, ambient-api-server-db patches).
Overlay: production
components/manifests/overlays/production/kustomization.yaml, components/manifests/overlays/production/*
Adds components list (oauth-proxy, postgresql-rhel, ambient-api-server-db) and removes many production-specific patch files that are now provided by components.
Overlay: local-dev
components/manifests/overlays/local-dev/kustomization.yaml
Adds component references (../../components/postgresql-rhel, ../../components/ambient-api-server-db), removes related inline patches, keeps credentials patch.
Overlay: kind & e2e
components/manifests/overlays/kind/kustomization.yaml, components/manifests/overlays/e2e/kustomization.yaml
Replaces direct resources/patches for PostgreSQL init scripts with references to the postgresql-init-scripts component; removes the corresponding patch and ConfigMap files from overlays.
Removed overlay patch files
components/manifests/overlays/production/ambient-api-server-db-json-patch.yaml, components/manifests/overlays/production/ambient-api-server-init-db-patch.yaml, components/manifests/overlays/production/postgresql-json-patch.yaml, components/manifests/overlays/production/unleash-init-db-patch.yaml, components/manifests/overlays/kind/postgresql-init-scripts-patch.yaml, components/manifests/overlays/kind/postgresql-init-scripts.yaml
Deleted multiple JSON/YAML patch files and an inline ConfigMap that previously added RHEL-postgres image/env/volume/probe changes and init-container/init-scripts logic; that functionality is moved into components.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: extracting shared patches into Kustomize Components for the manifests.
Description check ✅ Passed The description is well-related to the changeset, explaining the split of base/ into sub-kustomizations, extraction of duplicated patches into components, and updates to overlays.
Linked Issues check ✅ Passed The PR successfully addresses issue #836 by extracting 10 duplicated patches across 4 overlays into 4 reusable Kustomize Components and reorganizing the base layer into core/rbac/platform sub-kustomizations.
Out of Scope Changes check ✅ Passed All changes are in scope: new component kustomization files, updated overlay kustomization files to reference components, and removal of duplicated patch files that were consolidated into components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kdreyer/refactor-kustomize
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.

mprpic
mprpic previously approved these changes Mar 16, 2026
@ktdreyer
Copy link
Contributor Author

Not sure why CodeRabbit did not review this. Maybe something on my ktdreyer GH account? I'm approved for a license (DPP-19771).

I'll use a command to trigger a review explicitly.

@ktdreyer
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ktdreyer
Copy link
Contributor Author

I see now. CodeRabbit won't actually leave a "comment" review if "No actionable comments were generated".

I filed #940 to clean up the mergify gate on this.

@ambient-code ambient-code bot removed this from the Review Queue milestone Mar 18, 2026
@ambient-code
Copy link
Contributor

ambient-code bot commented Mar 18, 2026

Review Queue Status

Check Status Detail
CI pass ✅ All checks passed
Conflicts FAIL ❌ Merge conflicts detected
Reviews pass ✅ Approved (mprpic)

Action needed: Rebase to resolve merge conflicts

Auto-generated by Review Queue workflow. Updated when PR changes.

Adding a new OpenShift overlay currently requires copying patch files
from an existing overlay and hoping nothing was missed. Kustomize
Components let overlays compose reusable mixins instead.

Split base/ into core/, rbac/, and platform/ sub-kustomizations so
future overlays can selectively include only what they need. Extract
10 duplicated patch files into 4 components:

- oauth-proxy: OAuth sidecar + service port (production)
- postgresql-rhel: RHEL postgres image + unleash init-db
- ambient-api-server-db: API server DB connection + init
- postgresql-init-scripts: ConfigMap-based DB init (kind/e2e)

Each overlay now references shared components instead of maintaining
its own copy of identical patches. All 5 overlays produce identical
"oc kustomize" output before and after this change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
components/manifests/overlays/production/kustomization.yaml (1)

52-88: 🧹 Nitpick | 🔵 Trivial

Consider normalizing image references in source manifests.

The images section contains duplicate entries for both tagged (vteam_backend:latest) and untagged (vteam_backend) variants of the same images. While this works correctly, it suggests inconsistent image references in the source manifests. If all source manifests used a consistent format, this duplication could be eliminated.

Low priority since the PR confirms identical output before/after.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/manifests/overlays/production/kustomization.yaml` around lines 52
- 88, The images list in kustomization.yaml contains duplicate entries for the
same images with and without the ":latest" tag (e.g., entries for
quay.io/ambient_code/vteam_backend and
quay.io/ambient_code/vteam_backend:latest, same for vteam_frontend,
vteam_claude_runner, vteam_operator, vteam_public_api, vteam_api_server,
vteam_state_sync); normalize the source manifests so image references are
consistent (choose either tagged form or untagged form) and remove the
duplicated image entries from the images section so each image (by name) appears
only once with its intended newName/newTag mapping.
components/manifests/overlays/local-dev/kustomization.yaml (1)

68-68: ⚠️ Potential issue | 🟡 Minor

Stale comment references removed patch file.

This comment references postgresql-json-patch.yaml, which was removed as part of this refactor. The PostgreSQL RHEL image handling is now provided by the ../../components/postgresql-rhel component. Update or remove this comment to avoid confusion.

Suggested fix
-# PostgreSQL: RHEL image handled via JSON patch (postgresql-json-patch.yaml)
+# PostgreSQL: RHEL image handled via postgresql-rhel component
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/manifests/overlays/local-dev/kustomization.yaml` at line 68, The
inline comment "# PostgreSQL: RHEL image handled via JSON patch
(postgresql-json-patch.yaml)" is stale; update or remove it so it correctly
references the current implementation at "../../components/postgresql-rhel"
instead of the removed "postgresql-json-patch.yaml". Locate the comment in the
kustomization.yaml and either replace the text to mention the
"../../components/postgresql-rhel" component or delete the comment entirely to
avoid confusion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@components/manifests/overlays/local-dev/kustomization.yaml`:
- Line 68: The inline comment "# PostgreSQL: RHEL image handled via JSON patch
(postgresql-json-patch.yaml)" is stale; update or remove it so it correctly
references the current implementation at "../../components/postgresql-rhel"
instead of the removed "postgresql-json-patch.yaml". Locate the comment in the
kustomization.yaml and either replace the text to mention the
"../../components/postgresql-rhel" component or delete the comment entirely to
avoid confusion.

In `@components/manifests/overlays/production/kustomization.yaml`:
- Around line 52-88: The images list in kustomization.yaml contains duplicate
entries for the same images with and without the ":latest" tag (e.g., entries
for quay.io/ambient_code/vteam_backend and
quay.io/ambient_code/vteam_backend:latest, same for vteam_frontend,
vteam_claude_runner, vteam_operator, vteam_public_api, vteam_api_server,
vteam_state_sync); normalize the source manifests so image references are
consistent (choose either tagged form or untagged form) and remove the
duplicated image entries from the images section so each image (by name) appears
only once with its intended newName/newTag mapping.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ab25cb4b-189a-421f-bc2f-4f18f38779f1

📥 Commits

Reviewing files that changed from the base of the PR and between 62dbc57 and 75b8991.

📒 Files selected for processing (41)
  • components/manifests/base/core/agent-registry-configmap.yaml
  • components/manifests/base/core/ambient-api-server-service.yml
  • components/manifests/base/core/backend-deployment.yaml
  • components/manifests/base/core/flags.json
  • components/manifests/base/core/flags.json.example
  • components/manifests/base/core/frontend-deployment.yaml
  • components/manifests/base/core/kustomization.yaml
  • components/manifests/base/core/minio-deployment.yaml
  • components/manifests/base/core/models.json
  • components/manifests/base/core/operator-deployment.yaml
  • components/manifests/base/core/postgresql-deployment.yaml
  • components/manifests/base/core/public-api-deployment.yaml
  • components/manifests/base/core/unleash-deployment.yaml
  • components/manifests/base/core/workspace-pvc.yaml
  • components/manifests/base/kustomization.yaml
  • components/manifests/base/platform/ambient-api-server-db.yml
  • components/manifests/base/platform/ambient-api-server-secrets.yml
  • components/manifests/base/platform/kustomization.yaml
  • components/manifests/base/platform/namespace.yaml
  • components/manifests/components/ambient-api-server-db/ambient-api-server-db-json-patch.yaml
  • components/manifests/components/ambient-api-server-db/ambient-api-server-init-db-patch.yaml
  • components/manifests/components/ambient-api-server-db/kustomization.yaml
  • components/manifests/components/oauth-proxy/frontend-oauth-deployment-patch.yaml
  • components/manifests/components/oauth-proxy/frontend-oauth-service-patch.yaml
  • components/manifests/components/oauth-proxy/kustomization.yaml
  • components/manifests/components/postgresql-init-scripts/kustomization.yaml
  • components/manifests/components/postgresql-init-scripts/postgresql-init-scripts-patch.yaml
  • components/manifests/components/postgresql-init-scripts/postgresql-init-scripts.yaml
  • components/manifests/components/postgresql-rhel/kustomization.yaml
  • components/manifests/components/postgresql-rhel/postgresql-json-patch.yaml
  • components/manifests/components/postgresql-rhel/unleash-init-db-patch.yaml
  • components/manifests/overlays/e2e/kustomization.yaml
  • components/manifests/overlays/kind/kustomization.yaml
  • components/manifests/overlays/kind/postgresql-init-scripts-patch.yaml
  • components/manifests/overlays/kind/postgresql-init-scripts.yaml
  • components/manifests/overlays/local-dev/kustomization.yaml
  • components/manifests/overlays/production/ambient-api-server-db-json-patch.yaml
  • components/manifests/overlays/production/ambient-api-server-init-db-patch.yaml
  • components/manifests/overlays/production/kustomization.yaml
  • components/manifests/overlays/production/postgresql-json-patch.yaml
  • components/manifests/overlays/production/unleash-init-db-patch.yaml
💤 Files with no reviewable changes (6)
  • components/manifests/overlays/production/postgresql-json-patch.yaml
  • components/manifests/overlays/production/ambient-api-server-init-db-patch.yaml
  • components/manifests/overlays/kind/postgresql-init-scripts-patch.yaml
  • components/manifests/overlays/kind/postgresql-init-scripts.yaml
  • components/manifests/overlays/production/ambient-api-server-db-json-patch.yaml
  • components/manifests/overlays/production/unleash-init-db-patch.yaml

@Gkrumbach07
Copy link
Contributor

@Mergifyio queue

@mergify
Copy link

mergify bot commented Mar 18, 2026

Merge Queue Status

This pull request spent 17 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify bot added the queued label Mar 18, 2026
mergify bot added a commit that referenced this pull request Mar 18, 2026
@mergify mergify bot merged commit c541bd9 into main Mar 18, 2026
20 checks passed
@mergify mergify bot deleted the kdreyer/refactor-kustomize branch March 18, 2026 17:25
@mergify mergify bot removed the queued label Mar 18, 2026
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.

kustomize layout is haphazard, and adding new targets is hard

3 participants