Skip to content

Add namespaces to different levels of deployable kustomizations#1475

Open
friegger wants to merge 1 commit into
mainfrom
chore/add-standalone-kustomizations
Open

Add namespaces to different levels of deployable kustomizations#1475
friegger wants to merge 1 commit into
mainfrom
chore/add-standalone-kustomizations

Conversation

@friegger
Copy link
Copy Markdown
Contributor

@friegger friegger commented May 22, 2026

Deal with namespaces more explicitly by adding them to kustomizations on different levels directly, eliminating the previous remove-namespace.yaml patch dance.

apiserver and controller components now have:

  • config//default/ - namespace+namePrefix only, emits no
    Namespace (used as a base)
  • config//standalone/ - wraps default/ and adds the
    ironcore-system Namespace; use this for
    single-component deploys

Shared Namespace lives in config/namespaces/ironcore-system/. The combined config/default and config/etcdless installs reference the bases and the Build output for both is byte-identical to main (only kustomize deprecation-warning lines disappear, since the patches that triggered them are gone).

The namespaces folder can be extended with additional namespaces, e.g. for the pool leases.

Behavioral change for downstream consumers of the low level kustomizations: users who previously ran kustomize build config/controller/default for a complete deploy must migrate to config/controller/standalone; same for config/apiserver/default -> config/apiserver/standalone (or config/apiserver/standalone-etcdless for the external-etcd variant).

Consumers must not apply namespace transformers in overlays, these will fail once we have multiple namespaces. This is true, independent of this change, once base kustomizations provide multiple namespaces.

The Makefile install/uninstall/deploy/undeploy targets are retargeted at the standalone variants accordingly. hack/validate-kustomize.sh is also made portable (GNU realpath --relative-to is unavailable on macOS).

Contributes to #1472

Summary by CodeRabbit

  • Chores
    • Reorganized deployment configuration structure to support multiple deployment scenarios including standalone and external etcd modes
    • Simplified namespace and configuration management for cleaner internal organization

Review Change Stack

apiserver and controller components now have:
- config/<component>/default/   - namespace+namePrefix only, emits no
                                  Namespace (used as a base)
- config/<component>/standalone/ - wraps default/ and adds the
                                  ironcore-system Namespace; use this for
                                  single-component deploys

Shared Namespace lives in config/namespaces/ironcore-system/. The combined
config/default and config/etcdless installs reference the bases and the
namespace kustomization directly, eliminating the previous
remove-namespace.yaml patch dance. Build output for both is byte-identical
to main (only kustomize deprecation-warning lines disappear, since the
patches that triggered them are gone).

The namespaces folder can be extended with additional namespaces, e.g. for
the pool leases.

Behavioral change for downstream consumers: users who previously ran
`kustomize build config/controller/default` for a complete deploy must
migrate to `config/controller/standalone`; same for
`config/apiserver/default` -> `config/apiserver/standalone` (or
`config/apiserver/standalone-etcdless` for the external-etcd variant).

Consumers must not apply namespace transformers in overlays, these
will fail once we have multiple namespaces.

The Makefile install/uninstall/deploy/undeploy targets are retargeted at
the standalone variants accordingly. hack/validate-kustomize.sh is also
made portable (GNU realpath --relative-to is unavailable on macOS).

Signed-off-by: Felix Riegger <felix.riegger@sap.com>
@friegger friegger requested a review from a team as a code owner May 22, 2026 07:17
@friegger friegger changed the title config: add namespaces to different levels of deployable kustomizations Add namespaces to different levels of deployable kustomizations May 22, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

📝 Walkthrough

Walkthrough

This PR refactors Kustomize namespace management by centralizing the ironcore-system namespace definition and explicitly composing it with deployment configurations via new standalone overlays, replacing the previous pattern of defining namespaces in multiple locations and removing them via strategic merge patches.

Changes

Kustomize Namespace Centralization Refactoring

Layer / File(s) Summary
Centralized namespace definition
config/namespaces/ironcore-system/kustomization.yaml, config/namespaces/ironcore-system/namespace.yaml
A new shared ironcore-system namespace is defined with the control-plane: apiserver-controller label and exposed through a Kustomization for reuse.
Apiserver standalone overlays
config/apiserver/standalone/kustomization.yaml, config/apiserver/standalone-etcdless/kustomization.yaml, config/apiserver/server/server.yaml
New standalone overlays explicitly compose the apiserver base with the centralized namespace; the Namespace block is removed from the apiserver manifest itself since it is now composed separately.
Controller standalone overlay
config/controller/standalone/kustomization.yaml, config/controller/manager/manager.yaml
New standalone overlay explicitly composes the controller base with the centralized namespace; the Namespace block is removed from the controller manifest.
Base and etcdless configurations
config/default/kustomization.yaml, config/etcdless/kustomization.yaml
Base configurations updated to reference the namespace-free apiserver and controller bases, then explicitly include the centralized ironcore-system namespace under resources.
Overlay and Makefile entry points
Makefile (lines 231–235, 239–244), config/apiserver/kind/kustomization.yaml, config/controller/kind/kustomization.yaml
Kind overlays and Makefile targets (install, uninstall, deploy, undeploy) updated to use the new standalone overlays instead of default.
Validation script update
hack/validate-kustomize.sh
Path display logic in the validation loop switched from realpath --relative-to to Bash parameter expansion for computing relative directory paths.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding namespaces to different levels of deployable kustomizations as described throughout the PR changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description is comprehensive and detailed, covering objectives, changes, behavioral impacts, and migration guidance for downstream consumers.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/add-standalone-kustomizations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@hack/validate-kustomize.sh`:
- Line 15: The prefix-removal pattern dir="${path#$BASEDIR/../}" can misbehave
if BASEDIR contains glob meta-characters; update the pattern to quote BASEDIR
inside the parameter expansion so the prefix is treated literally (i.e. use the
variable name BASEDIR within the ${path#...} expression in a quoted form) —
modify the occurrence of ${path#$BASEDIR/../} to use a quoted BASEDIR in the
pattern so dir assignment is robust against globbing.

In `@Makefile`:
- Line 235: The uninstall/undeploy Makefile targets currently run "kubectl
delete -k config/apiserver/standalone" (and a similar line at the other
occurrence) which deletes the shared ironcore-system Namespace; change these
targets to avoid removing the Namespace by either pointing to a kustomize
overlay that excludes the Namespace resource or by splitting namespace lifecycle
into a separate explicit target (e.g., "uninstall-namespace") and having
uninstall/undeploy call only component-specific deletions; update the lines
containing "kubectl delete -k config/apiserver/standalone" (and the second
similar delete) to use the non-namespace overlay or remove the Namespace
deletion so removing one component won’t tear down the other.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 22fdf563-639d-4a15-b423-ecfe90aed72e

📥 Commits

Reviewing files that changed from the base of the PR and between 4cd4d58 and caaf1d3.

📒 Files selected for processing (23)
  • Makefile
  • config/apiserver/kind/kustomization.yaml
  • config/apiserver/server/server.yaml
  • config/apiserver/standalone-etcdless/kustomization.yaml
  • config/apiserver/standalone/kustomization.yaml
  • config/controller/kind/kustomization.yaml
  • config/controller/manager/manager.yaml
  • config/controller/standalone/kustomization.yaml
  • config/default/apiserver/kustomization.yaml
  • config/default/apiserver/remove-namespace.yaml
  • config/default/controller/kustomization.yaml
  • config/default/controller/remove-namespace.yaml
  • config/default/kustomization.yaml
  • config/default/namespace.yaml
  • config/etcdless/apiserver/kustomization.yaml
  • config/etcdless/apiserver/remove-namespace.yaml
  • config/etcdless/controller/kustomization.yaml
  • config/etcdless/controller/remove-namespace.yaml
  • config/etcdless/kustomization.yaml
  • config/etcdless/namespace.yaml
  • config/namespaces/ironcore-system/kustomization.yaml
  • config/namespaces/ironcore-system/namespace.yaml
  • hack/validate-kustomize.sh
💤 Files with no reviewable changes (12)
  • config/etcdless/controller/remove-namespace.yaml
  • config/default/namespace.yaml
  • config/etcdless/apiserver/remove-namespace.yaml
  • config/default/controller/remove-namespace.yaml
  • config/etcdless/namespace.yaml
  • config/etcdless/apiserver/kustomization.yaml
  • config/default/apiserver/remove-namespace.yaml
  • config/default/apiserver/kustomization.yaml
  • config/default/controller/kustomization.yaml
  • config/etcdless/controller/kustomization.yaml
  • config/controller/manager/manager.yaml
  • config/apiserver/server/server.yaml

for kustomization in "$BASEDIR"/../config/*/**/kustomization.yaml; do
path="$(dirname "$kustomization")"
dir="$(realpath --relative-to "$BASEDIR"/.. "$path")"
dir="${path#$BASEDIR/../}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant lines (including neighbors) around the referenced line
echo "== hack/validate-kustomize.sh (lines 1-40) =="
nl -ba hack/validate-kustomize.sh | sed -n '1,40p'

echo "== hack/validate-kustomize.sh: occurrences of BASEDIR and path#"$'\n'"BASEDIR =="
rg -n 'BASEDIR|path#\$\{?BASEDIR\}?|path#\$\BASEDIR|dir="\$\{path#\$\BASEDIR/.*\}"' hack/validate-kustomize.sh || true

Repository: ironcore-dev/ironcore

Length of output: 172


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== hack/validate-kustomize.sh (lines 1-60) =="
awk 'NR>=1 && NR<=60 {printf "%4d\t%s\n", NR, $0}' hack/validate-kustomize.sh

echo "== BASEDIR definitions/usages =="
rg -n 'BASEDIR|path#\$\{?BASEDIR\}?|dir="\$\{path#\$\{?BASEDIR\}?/.*"' hack/validate-kustomize.sh || true

Repository: ironcore-dev/ironcore

Length of output: 1059


Quote BASEDIR in the ${path#...} pattern to avoid globbing edge cases.

At Line 15, dir="${path#$BASEDIR/../}" uses prefix removal with a pattern; since BASEDIR is derived from filesystem paths (pwd), it could contain glob metacharacters, changing how stripping behaves. Quote the BASEDIR portion so it’s treated literally.

Proposed fix
-  dir="${path#$BASEDIR/../}"
+  dir="${path#"$BASEDIR"/../}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dir="${path#$BASEDIR/../}"
dir="${path#"$BASEDIR"/../}"
🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 15-15: Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.

(SC2295)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hack/validate-kustomize.sh` at line 15, The prefix-removal pattern
dir="${path#$BASEDIR/../}" can misbehave if BASEDIR contains glob
meta-characters; update the pattern to quote BASEDIR inside the parameter
expansion so the prefix is treated literally (i.e. use the variable name BASEDIR
within the ${path#...} expression in a quoted form) — modify the occurrence of
${path#$BASEDIR/../} to use a quoted BASEDIR in the pattern so dir assignment is
robust against globbing.

Comment thread Makefile
.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall API server & API services from the K8s cluster specified in ~/.kube/config.
kubectl delete -k config/apiserver/default
kubectl delete -k config/apiserver/standalone
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid deleting the shared namespace from single-component teardown targets.

uninstall and undeploy now delete standalone kustomizations that include ironcore-system. If both components are installed independently, removing one can delete the namespace and tear down the other component unexpectedly.

Use delete targets that exclude the Namespace (or split namespace lifecycle into a separate explicit target).

Also applies to: 244-244

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` at line 235, The uninstall/undeploy Makefile targets currently run
"kubectl delete -k config/apiserver/standalone" (and a similar line at the other
occurrence) which deletes the shared ironcore-system Namespace; change these
targets to avoid removing the Namespace by either pointing to a kustomize
overlay that excludes the Namespace resource or by splitting namespace lifecycle
into a separate explicit target (e.g., "uninstall-namespace") and having
uninstall/undeploy call only component-specific deletions; update the lines
containing "kubectl delete -k config/apiserver/standalone" (and the second
similar delete) to use the non-namespace overlay or remove the Namespace
deletion so removing one component won’t tear down the other.

@hardikdr hardikdr added the area/iaas Issues related to IronCore IaaS development. label May 22, 2026
@hardikdr hardikdr added this to Roadmap May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/iaas Issues related to IronCore IaaS development. chore size/L

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants