docs(design): add per-FD BMH namespace placement to fd-datatemplate-selection - #689
docs(design): add per-FD BMH namespace placement to fd-datatemplate-selection#689shibaPuppy wants to merge 1 commit into
Conversation
…election Signed-off-by: shibaPuppy <sub951@naver.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @shibaPuppy. Thanks for your PR. I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
lentzi90
left a comment
There was a problem hiding this comment.
Thank you for the proposal!
Unfortunately I do not think this is a good idea. At least not without further adjustments and security/multi-tenancy considerations.
My main objection is that this would make it possible for a user with Metal3 privileges in namespace A to "hijack" BareMetalHosts in any other namespace, even if they have no privileges there.
I think we will need to think about how the HostClaim or CAPM3 multi-tenancy proposal could be extended instead to support failure domains, instead of adding it on separately, on top of the current API directly.
|
@lentzi90 thanks for catching this — let me lay out the threat model I have in mind and check whether it matches your concern. this proposal targets a single-tenant, multi-site deployment. The per-FD namespaces represent physical sites (rack / AZ / power domain), not tenants — one operator owns the HostClaim and the multi-tenancy proposal remain the right answer when namespaces are tenant boundaries. The two designs are complementary, not alternatives: HostClaim provides a cross-tenant API for BMH sharing; this proposal provides FD-aware placement for a single tenant's hardware. the proposal does not expand the controller's reach. Two existing mechanisms already cover the relevant boundary:
in short, the underlying concern — cross-namespace BMH consumption — applies to HostClaim as well, since HostClaim's whole point is to let a tenant consume BMHs from another namespace. HostClaim addresses this with beyond the namespace-A-hijacks-namespace-B scenario you raised, are there other escalation paths you'd want me to consider for this design? I want to make sure the runtime boundary ( If I've mischaracterized anything above (especially the HostClaim model), please correct me — I'd appreciate it. |
|
@shibaPuppy I understand the intended use-case, and in that situation it would be ok. However, there are also use-cases that rely on RBAC and controller behavior for multi-tenancy between namespaces. I.e. without deploying separate BMO instances for each group of These use-cases would be broken by the per-FD BMH namespace since there is no way to opt out of it. If we add the field, then any user who can create a Metal3Cluster can also set this field and break the namespace boundary. You are correct that the controller itself does not get any more privileges with this proposal. However, the expected behavior is that user privileges are controlled through RBAC. We must make sure that they cannot escalate privileges by abusing the controller. One of the most common ways this can happen is exactly the situation in this proposal. We let users access objects in namespaces outside their own reach, through the controller. One example of what this could lead to is this:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the FailureDomain-aware DataTemplate selection design to also describe an opt-in per-failure-domain BareMetalHost (BMH) namespace placement mechanism (bmhNamespace) in Metal3Cluster.Spec.FailureDomains, intended to support site/rack/AZ separation via namespaces and to compose with per-FD Metal3DataTemplate selection.
Changes:
- Expands the proposal and motivation to include namespace-based site separation for BMHs via a per-FD
bmhNamespacefield. - Documents expected controller behavior/lookup paths that must honor cross-namespace BMH placement, plus an example scenario and backward-compatibility notes.
- Adds related links and an alternatives section discussing
HostSelector-based namespace selection.
Comments suppressed due to low confidence (3)
design/fd-datatemplate-selection.md:53
- Terminology/style: per
design/bare-metal-style-guide.md, in prose use “bare metal” (noun) or “bare-metal” (adjective). “baremetal infrastructure” should be updated to the appropriate form to match the repo’s convention.
As an operator who has placed their baremetal infrastructure across different
FDs with **different network segments** (subnets, VLANs, IP pools), I would
design/fd-datatemplate-selection.md:559
- Same terminology concern as above: “BMH
ownerReferenceremoval” is ambiguous/mismatched with the KubernetesownerReferencesfield. Please align the wording toownerReferences(or explicitly describe removal of the Metal3Machine ownerReference entry).
- Requires PR [#2506][pr-2506]. The earliest CAPM3 release that can
carry it is the same release that ships the BMH `ownerReference`
removal.
design/fd-datatemplate-selection.md:592
- The Kubernetes concept/field is
ownerReferences(plural). Consider updating the link text to match (or to the exact title of the referenced issue) to avoid implying a non-existentownerReferencefield.
- [PR metal3-io/cluster-api-provider-metal3#2506 — Remove Metal3Machine owner reference from BMH][pr-2506]
- [Kubernetes #94631 — ownerReference cross-namespace](https://github.com/kubernetes/kubernetes/issues/94631)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| that physical site boundaries (rack, row, AZ) map directly to Kubernetes | ||
| namespace boundaries. Both are independently opt-in. (2) depends on PR | ||
| [metal3-io/cluster-api-provider-metal3#2506][pr-2506], which removes the | ||
| BMH `ownerReference`. |
|
@lentzi90 i understood the cleanest opt-out lever that doesn't require new admin machinery is RBAC itself: gate in other words, the admin's existing
would the following doc updates work for you?
Let me know if you'd want a stricter check. I went with |
|
I have not come across any such setup before, with a validating webhook that would check RBAC permissions as part of validation. This makes me quite skeptical of it, but I am willing to consider it.
Given the above, do you think it is worth it? Do you see other ways of achieving the same (e.g. using HostClaims or the multi-tenancy proposal) that would avoid these concerns? I would also be interested in @tuminoid 's input as security lead. |
|
would a feature-gate-based controller change work here, without adding any new fields to the CRDs? concretely:
to clarify the asymmetry: the proposal doesn't move on HostClaim as the long-term alternative: architecturally it lines up well — If this direction works, I'd update the doc in this PR to drop the Does this direction work for you? Welcome @tuminoid 's input as well from a security standpoint. |
|
Sorry, I don't think this is a good idea. Feature gates are normally expected to graduate and become the default behavior at some point. I don't see this happening for this feature. There is too much risk and we would end up doing double work for something that we can anyway get with HostClaims. I would much rather focus on implementing HostClaim support in CAPM3. One of the main points with the HostClaim feature is that we reduce the control CAPM3 and CAPM3 users have over the BMHs. We do not want to make CAPM3 pick BMHs across namespaces. Instead it should create HostClaims and be assigned BMHs based on the policy that the BMH owner decides. There is already agreement about implementing HostClaims. I understand that it may seem like it will take a long time until it is fully implemented, but please understand that getting consensus in the community, deciding what to actually implement, this usually takes more time than actually implementing it. You are very welcome to help with the implementation also. When there is an already accepted design doc it is usually quite easy to get the PR merged. |
Let's see if I follow the discussion and whats asked here. I did not check the whole proposal, just the discussion. I have not come across webhooks doing SAR, the API roundtrip back to API server is problematic as @lentzi90 pointed out. Safeguards are in the controllers, we have implemented few of those more recently. What the controller then checks is some sort of opt-in mechanism, which is often a CR in target namespace, which hence can be created by the namespace owner or the infra admin. As said yourself, this is done in the HostClaim too and we have these safeguards in place all over the code. I see no reason to try reinvent the wheel here. WATCH_NAMESPACES is deployment level knob, and as we've noticed on the BMO, it is not properly supported on controller-runtime. Using it to fix confused deputy doesn't work, as its all or nothing, making no difference between users or RBAC. |
|
@lentzi90 @tuminoid understood, thank you. before I start, could you help me with:
once the HostClaim design on the CAPM3 side lands, I'll bring the FD use case back as a separate proposal. |
|
Thanks for understanding! There is a large github discussion about HostClaim implementation details here: https://github.com/orgs/metal3-io/discussions/2795. I am also open to FD-related improvements in the current API, but of course these must be "reasonable" as discussed above. |
proposing an opt-in
bmhNamespacefield on eachMetal3Cluster.Spec.FailureDomainsentry, so each failure domain can be backed by its own BareMetalHost namespace.composes with the existing per-FD
DataTemplateselection.