Repository navigation
Ship an optional admission policy reserving IPAddressClaim.spec.addressName - #13
Timofei Larkin (lllamnyp) wants to merge 1 commit into
Conversation
…ssName A claim that names an address binds that Available address of its class, so whoever can create claims can pick addresses by name. The chart can now install a ValidatingAdmissionPolicy that lets only allowlisted principals set, change or remove the field, comparing old against new so unchanged writes pass. Off by default; namespace selector, exemptions and validation actions are values. make test runs it against envtest. Assisted-By: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
IvanHunters
left a comment
There was a problem hiding this comment.
Review: optional admission policy reserving IPAddressClaim.spec.addressName
Conforms to the design, which says spec.addressName cannot be resolved in CEL and a deployment either refuses the field to tenant principals or checks it in a webhook; this ships the "refuse to tenants" option. The CEL is correct: the deny predicate is newAddressName == oldAddressName (chart/address-controller/templates/admission-policy.yaml:37), the oldObject access is guarded by a request.operation == "UPDATE" short-circuit so there is no null dereference on CREATE, both CREATE and UPDATE are matched (a tenant setting the field at create is denied because oldAddressName is empty), failurePolicy: Fail is fail-closed, and the groups match is has()-guarded.
Two things done right that are worth calling out: the controller's ServiceAccount is deliberately NOT allowlisted, which is correct because the controller only reads claim.Spec.AddressName and never writes it (unlike the metallb-iad driver, which writes the gated Service fields and so must self-allowlist); and spec.className is left ungated, matching the design's decision to defer class entitlement to a separate object above this component.
[MINOR] Default namespaceSelector: {} applies cluster-wide
With enabled: true and the defaults the policy matches every namespace. This fails safe (more gating, not less), the values and README say to scope it, and it matches the sibling default, so it is a note rather than a defect.
LGTM.
The
ip-address-claimsproposal's Security section saysspec.addressName"cannot be checked in CEL, because resolving an address to its class needs a second object read. A deployment either refuses the field to tenant principals, which is the reference policy's choice, or checks it in a webhook." Neither address-controller nor metallb-iad shipped that refusal. A review of cozystack/cozystack#3382 also noted that any tenant can take anyAvailableaddress through the field. Stacked on #12.Changes
Policy.
templates/admission-policy.yamlinstallsaddress-controller-claim-address-name, aValidatingAdmissionPolicyand binding, whenadmissionPolicy.enabledis set (default off).CREATE/UPDATE, it refuses any non-allowlisted principal that sets, changes or removesspec.addressName.failurePolicy: Fail.Values.
validationActions(default[Deny]),namespaceSelector(default all namespaces),allowedUsernames, andallowedGroups(defaultsystem:mastersandkubeadm:cluster-admins, because admission policies bindsystem:masterstoo). In brokered mode, machinery that moves addresses between namespaces throughspec.addressNamemust be listed.Test.
test/admission/policy_test.gostarts envtest with the chart's CRDs and renders the policy withhelm template. It then checks, as server-side dry runs under impersonated identities:make testalready provides envtest assets. With the rule replaced bytrue, the test fails.README. A new Admission policy section.
Not covered
Which classes a namespace may claim from at all. The proposal leaves that to an entitlement object, still open.