Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/fleet-multiplane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ func run() error {
if err != nil {
return err
}
// The worker may get only its own assignment's payload object, which
// federation delivers beside the handoff.
runner.Payloads = coordination.HandoffPayloads{API: api, Namespace: coordinationNamespace, Cell: *cell}
err = cellView.Work(ctx, *handoff, runner)
fmt.Fprintf(os.Stderr, "site-worker: handoff %s: %s\n", *handoff, classify(err))
switch {
Expand Down
4 changes: 2 additions & 2 deletions config/multiplane/cell-federation/federation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kind: Role
metadata: {name: fleet-federation, namespace: fleet-coordination}
rules:
- apiGroups: [coordination.fleet.datumapis.com]
resources: [machineallocationhandoffs]
resources: [machineallocationhandoffs, machineallocationpayloads]
verbs: [get, list, watch, create, update, patch, delete]
- apiGroups: [""]
resources: [events]
Expand All @@ -30,7 +30,7 @@ kind: ClusterRole
metadata: {name: fleet-federation-discovery}
rules:
- apiGroups: [coordination.fleet.datumapis.com]
resources: [machineallocationhandoffs]
resources: [machineallocationhandoffs, machineallocationpayloads]
verbs: [get, list, watch]
- apiGroups: [""]
resources: [nodes, pods, namespaces]
Expand Down
41 changes: 41 additions & 0 deletions config/multiplane/coordination/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,47 @@ spec:
type: string
minLength: 1
maxLength: 65536
# The assignment's MachineAllocationPayload, derived from the
# handoff; the assignment's worker may get only it.
payload: {type: string, pattern: '^op-[a-f0-9]{40}-payload$'}
status:
type: object
x-kubernetes-preserve-unknown-fields: true
---
# An assignment's bootstrap payload, beside its handoff and never inside it.
# A dedicated kind, not a Secret: RBAC on it reaches only payloads, so the
# federation member, kro and each worker need no Secret permission, and no
# BMC credential is exposed to grant one.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: machineallocationpayloads.coordination.fleet.datumapis.com
annotations:
kustomize.toolkit.fluxcd.io/prune: disabled
spec:
group: coordination.fleet.datumapis.com
scope: Namespaced
names:
plural: machineallocationpayloads
singular: machineallocationpayload
kind: MachineAllocationPayload
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
required: [spec]
properties:
spec:
type: object
required: [cell, payload]
x-kubernetes-validations:
- rule: self == oldSelf
message: A payload is immutable
properties:
cell: {type: string, minLength: 1, maxLength: 63}
# The site payload JSON: reference, salted digest, salt and
# data, base64. At most 96 KiB of encoded data.
payload: {type: string, format: byte, minLength: 1, maxLength: 262144}
5 changes: 5 additions & 0 deletions config/multiplane/karmada-api/hub-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ rules:
resources: [machineallocationhandoffs]
# patch marks a handoff's result answered; the spec stays immutable.
verbs: [get, list, watch, create, patch]
# The courier writes each assignment's payload, checks an existing one,
# and deletes it once the result is answered or the operation ends.
- apiGroups: [coordination.fleet.datumapis.com]
resources: [machineallocationpayloads]
verbs: [get, list, create, delete]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down
7 changes: 7 additions & 0 deletions config/multiplane/karmada-members/members.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ spec:
labelSelector:
matchLabels:
coordination.fleet.datumapis.com/cell: "${FLEET_CELL}"
# An assignment's bootstrap payload travels beside its handoff. Deleting
# it on the hub deletes the cell's copy.
- apiVersion: coordination.fleet.datumapis.com/v1alpha1
kind: MachineAllocationPayload
labelSelector:
matchLabels:
coordination.fleet.datumapis.com/cell: "${FLEET_CELL}"
placement:
clusterAffinity:
clusterNames:
Expand Down
61 changes: 55 additions & 6 deletions config/site/base/kro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
# Jobs and ServiceAccounts in fleet-site, Roles and RoleBindings in
# fleet-coordination. kro holds no Deployment, Service, volume, ConfigMap or
# Secret write and no handoff spec or status write. To create a per-operation
# Role granting get on one handoff, kro itself must hold that get permission.
# Role granting get on one handoff and on its one payload, kro itself must
# hold get on both kinds, and it holds nothing more on payloads: no list,
# watch or write, and no escalate or bind. The worker identity policy admits
# only the per-operation Role and binding shapes, and the cluster RBAC policy
# refuses every cluster-wide Role or binding kro writes.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down Expand Up @@ -59,6 +63,9 @@ rules:
- apiGroups: [rbac.authorization.k8s.io]
resources: [roles, rolebindings]
verbs: [create, update, patch, delete]
- apiGroups: [coordination.fleet.datumapis.com]
resources: [machineallocationpayloads]
verbs: [get]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down Expand Up @@ -120,6 +127,19 @@ spec:
!has(variables.pod.volumes) || variables.pod.volumes.all(v,
(has(v.persistentVolumeClaim) && v.persistentVolumeClaim.claimName == 'fleet-site-state') || has(v.emptyDir))
message: a worker Job may mount only the site journal claim and emptyDir
# The kubelet resolves Secret references for a Pod whatever its
# ServiceAccount may read, so a worker takes environment only from
# literal values and the site enrollment.
- expression: >-
variables.pod.containers.all(c, !has(c.envFrom) && (!has(c.env) || c.env.all(e, !has(e.valueFrom) ||
(has(e.valueFrom.configMapKeyRef) && e.valueFrom.configMapKeyRef.name == 'fleet-site-enrollment' &&
!has(e.valueFrom.secretKeyRef) && !has(e.valueFrom.fieldRef) && !has(e.valueFrom.resourceFieldRef)))))
message: a worker Job may take environment only from literal values and the site enrollment
- expression: >-
variables.pod.containers.all(c, !has(c.args) && has(c.command) && size(c.command) == 6 &&
c.command[0] == 'fleet-multiplane' && c.command[1] == 'site-worker' &&
c.command[2] == '--handoff' && c.command[3] == variables.handoff && c.command[4] == '--cell')
message: a worker Job must run only the site worker for its own handoff
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
Expand Down Expand Up @@ -158,11 +178,16 @@ spec:
- expression: "variables.kind != 'serviceaccounts' || request.namespace == 'fleet-site'"
message: worker ServiceAccounts live in fleet-site
- expression: >-
variables.kind != 'roles' || (has(object.rules) && size(object.rules) == 1 &&
object.rules.all(r, r.apiGroups == ['coordination.fleet.datumapis.com'] &&
r.resources == ['machineallocationhandoffs'] && r.verbs == ['get'] &&
has(r.resourceNames) && r.resourceNames == [variables.handoff]))
message: a worker Role may grant only get on its own handoff
variables.kind != 'roles' || (has(object.rules) && size(object.rules) == 2 &&
object.rules[0].apiGroups == ['coordination.fleet.datumapis.com'] &&
object.rules[0].resources == ['machineallocationhandoffs'] && object.rules[0].verbs == ['get'] &&
has(object.rules[0].resourceNames) && object.rules[0].resourceNames == [variables.handoff] &&
!has(object.rules[0].nonResourceURLs) &&
object.rules[1].apiGroups == ['coordination.fleet.datumapis.com'] &&
object.rules[1].resources == ['machineallocationpayloads'] && object.rules[1].verbs == ['get'] &&
has(object.rules[1].resourceNames) && object.rules[1].resourceNames == [variables.handoff + '-payload'] &&
!has(object.rules[1].nonResourceURLs))
message: a worker Role may grant only get on its own handoff and on its own payload
- expression: >-
variables.kind != 'rolebindings' || (object.roleRef.kind == 'Role' &&
object.roleRef.name == object.metadata.name && has(object.subjects) && size(object.subjects) == 1 &&
Expand All @@ -176,3 +201,27 @@ metadata: {name: fleet-site-kro-worker-identity}
spec:
policyName: fleet-site-kro-worker-identity
validationActions: [Deny]
---
# kro holds no cluster-wide RBAC write, and this refuses one anyway: a graph
# revision must never create or change a ClusterRole or ClusterRoleBinding.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata: {name: fleet-site-kro-cluster-rbac}
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- {apiGroups: [rbac.authorization.k8s.io], apiVersions: ["*"], resources: [clusterroles, clusterrolebindings], operations: [CREATE, UPDATE, DELETE]}
matchConditions:
- name: kro-controller
expression: "request.userInfo.username == 'system:serviceaccount:kro-system:kro'"
validations:
- expression: "false"
message: kro may not write cluster-wide RBAC
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata: {name: fleet-site-kro-cluster-rbac}
spec:
policyName: fleet-site-kro-cluster-rbac
validationActions: [Deny]
8 changes: 7 additions & 1 deletion config/site/graph/rgd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ spec:
operator: In
values: [assignment]
# Per-operation identity and policy: each worker may read exactly its own
# handoff and nothing else. It has no status, list or Secret permission.
# handoff and its own payload, which exists only for an operation with
# bootstrap data, and nothing else. It has no status, list or Secret
# permission.
# The fleet-site-kro-worker-identity admission policy enforces this shape.
- id: workerAccounts
includeWhen:
Expand Down Expand Up @@ -127,6 +129,10 @@ spec:
resources: [machineallocationhandoffs]
resourceNames: ["${handoff.metadata.name}"]
verbs: [get]
- apiGroups: [coordination.fleet.datumapis.com]
resources: [machineallocationpayloads]
resourceNames: ["${handoff.metadata.name + '-payload'}"]
verbs: [get]
- id: workerBindings
includeWhen:
- ${schema.spec.dispatch}
Expand Down
16 changes: 11 additions & 5 deletions config/site/redfish/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ patches:
patch: |-
- op: test
path: /spec/validations/2/message
value: a worker Role may grant only get on its own handoff
value: a worker Role may grant only get on its own handoff and on its own payload
- op: replace
path: /spec/matchConstraints/namespaceSelector/matchExpressions/0/values
value: [fleet-site, fleet-coordination, fleet-site-credentials, fleet-site-worker-identity]
Expand All @@ -51,7 +51,13 @@ patches:
request.namespace == 'fleet-site-worker-identity' ?
(has(object.rules) && size(object.rules) == 1 && object.rules.all(r, r.apiGroups == [''] &&
r.resources == ['secrets'] && r.verbs == ['get'] && has(r.resourceNames) && r.resourceNames == ['fleet-site-worker-media'])) :
(has(object.rules) && size(object.rules) == 1 && object.rules.all(r, r.apiGroups == ['coordination.fleet.datumapis.com'] &&
r.resources == ['machineallocationhandoffs'] && r.verbs == ['get'] &&
has(r.resourceNames) && r.resourceNames == [variables.handoff])))
message: a worker Role may grant only get on its own handoff, get on one named BMC credential, or get on the site worker identity
(has(object.rules) && size(object.rules) == 2 &&
object.rules[0].apiGroups == ['coordination.fleet.datumapis.com'] &&
object.rules[0].resources == ['machineallocationhandoffs'] && object.rules[0].verbs == ['get'] &&
has(object.rules[0].resourceNames) && object.rules[0].resourceNames == [variables.handoff] &&
!has(object.rules[0].nonResourceURLs) &&
object.rules[1].apiGroups == ['coordination.fleet.datumapis.com'] &&
object.rules[1].resources == ['machineallocationpayloads'] && object.rules[1].verbs == ['get'] &&
has(object.rules[1].resourceNames) && object.rules[1].resourceNames == [variables.handoff + '-payload'] &&
!has(object.rules[1].nonResourceURLs)))
message: a worker Role may grant only get on its own handoff and on its own payload, or get on one named BMC credential or the site worker identity
8 changes: 3 additions & 5 deletions docs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ is implemented on the same custody, and nothing creates power operations yet.
[OS images and bootstrap data](machine-images.md) has its image catalog
**implemented**: a provider-published, digest-pinned `MachineImage` that
admission resolves through a publication record and checks against the
server's architecture and firmware mode. The sealed bootstrap store is
**implemented** through the simulator site; federation and the lab sites do
not carry bootstrap data yet.
server's architecture and firmware mode. The simulator uses the sealed bootstrap store. Federation and guest seed
delivery are exercised only by isolated tests, not enabled in deployments.

The opt-in [multi-plane acceptance harness](../operations/multiplane.md) composes
the [local VM site](../operations/local-vm.md) with native Milo project APIs, the
Expand Down Expand Up @@ -822,7 +821,6 @@ acceptance inventory.
site credential protocol.
- The capacity projector is unwired (O1); see
[Device custody](device-custody.md#points-for-a-person). Bootstrap data
reaches only the simulator site; see [OS images and bootstrap
data](machine-images.md).
delivery is described in [OS images and bootstrap data](machine-images.md).
- The site store is intended for a single site process per Device. Replication,
migration, backup, and upgrade/downgrade compatibility are not implemented.
4 changes: 2 additions & 2 deletions docs/development/device-custody.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ a Machine status, update or patch permission.

### Unchanged and still open

- Bootstrap data reaches only the simulator site. See
- Only isolated tests deliver bootstrap data to federated network-boot workers. See
[OS images and bootstrap data](machine-images.md).
- `DeviceRecovery` needs no second person.

Expand Down Expand Up @@ -1483,7 +1483,7 @@ Increment B's site tests run with `go test -race ./internal/site/...`:
| One worker per assignment, final results, shutdown at each stage, an older worker that does not stop, a fence raised between journal and send | `TestARedeliveryWhileTheSameOperationRunsStoresNothing`, `TestACopyWaitingForTheLockReturnsTheStoredResult`, `TestAStoredResultSurvivesARedelivery`, `TestAWorkerStoppedFromOutsideStoresNoResult`, `TestAShutdownWhileWaitingForTheRunLockStoresNothing`, `TestAShutdownDuringTheChecksStoresNothing`, `TestANewerAssignmentThatCannotStopTheOlderWorkerSendsNothing`, `TestALostLockWithJournaledStepsIsUnknown`, `TestAFenceRaisedBetweenJournalAndSendStopsTheStep` |
| Per-Device credentials, the fence report | `TestSecretCredentialsUseThePerDeviceContract`, `TestReportGivesTheCoordinatorSeenAndStoppedFences` |
| Step payloads, the start-by window, identity separate from capabilities, a resumed worker reporting unknown | `TestAStepPayloadIsJournaledAndReadBack`, `TestALateStartIsStaleAndSendsNothing`, `TestIdentityIsSeparateFromInstallCapabilities`, `TestAResumedWorkerThatCannotReachTheBMCReportsUnknown` |
| Install and wipe against a simulated BMC, one power-on per phase after an interruption in either phase, the power-off bound, fenced boot admission, bootstrap refused by a site that cannot hand it on | `TestAWorkerInterruptedInTheDiskPhaseResumes`, `TestAServerThatNeverPowersOffEndsTheStep`, `TestInstallationRunsBothPhasesWithOneOnEach`, `TestWipeChecksTheEnrolledDisk`, `TestAnInterruptedWorkerResumesWithoutASecondOn`, `TestOnlyTheCurrentFenceHasAnOpenBootAdmission`, `TestBootstrapIsRefusedAtTheSiteToo` |
| Install and wipe against a simulated BMC, one power-on per phase after an interruption in either phase, the power-off bound, fenced boot admission, bootstrap data the installer verifies on disk, bootstrap refused without a payload | `TestAWorkerInterruptedInTheDiskPhaseResumes`, `TestAServerThatNeverPowersOffEndsTheStep`, `TestInstallationRunsBothPhasesWithOneOnEach`, `TestWipeChecksTheEnrolledDisk`, `TestAnInterruptedWorkerResumesWithoutASecondOn`, `TestOnlyTheCurrentFenceHasAnOpenBootAdmission`, `TestTheInstallerVerifiesBootstrapDataOverRedfish`, `TestBootstrapWithoutAPayloadSendsNothing` |

Increment C's tests run with `task test:envtest`, and the smoke runs with
`task standalone:test`:
Expand Down
Loading
Loading