Skip to main content

Module apply

Module apply 

Source
Expand description

Ownership-checked server-side apply, create-only Secret and delete. Ownership-checked Kubernetes writes for the RADIUS controller.

Every generated object is checked with ensure_not_foreign before the controller touches it, so a same-named Deployment or Service created by someone else is reported as a conflict and never adopted, even when its labels match. Generated objects are written with server-side apply under FIELD_MANAGER with force, so a conflict with another field manager (for example kubectl scale) cannot wedge the reconcile with a 409. Config Secrets are create-only and immutable; deletes carry UID and resourceVersion preconditions so a recreated object is never removed.

Server-side apply cannot be made conditional on non-existence, so a foreign object created between the read and the patch would be merged into. The patch response is therefore checked again and a foreign result is reported as a conflict; the window is a single API round trip.

Enums§

DeleteMode
How an object is deleted.
DeleteOutcome
What delete_owned did.
SecretOutcome
What ensure_config_secret did.

Constants§

FIELD_MANAGER
Server-side apply field manager.

Functions§

apply_owned
Server-side apply desired unless a foreign object holds the name.
apply_params
Parameters for every server-side apply: our field manager, with force.
check_not_foreign
Read the object if present and fail on a foreign one, without writing. Use it to refuse early (for example before minting a token).
delete_owned
Delete an object we control. Absent is success; a foreign object is an error and is never touched; failed preconditions are ExecError::ConcurrentMutation (re-observe and retry).
delete_params
Bind a delete to the exact object that was checked: a name can be deleted and recreated between GET and DELETE, and without both preconditions the replacement would be removed.
ensure_config_secret
Create the immutable config Secret if absent. Never patches or overwrites: an existing Secret (found by GET, or by a 409 from a racing reconcile) must be ours and identical, otherwise it is a conflict.
ensure_not_foreign
Reject an existing object that is not controlled by owner.
is_controlled_by
Is meta controlled by owner? The controller reference (at most one per object) must name the owner’s UID and kind. Extra non-controller references are allowed; a missing, different or non-controller reference is not ours.
verify_existing_secret
The existing Secret must be ours and byte-for-byte what we would create: same type, immutability, data, token id and rotation request. The name is content-addressed, so a difference means a conflicting writer, not a stale read.